Tuesday, September 16, 2014

Serial2tcp sharing a serial port on your computer to a remote device

There are dozens of ways to connect to remote devices from XTension but it occurred to me that there isn’t a simple way to just share one connected to another Mac. This little app will connect a local serial port on any Mac to a TCP port. Listen for a connection to the port and then forward data between the two. It can connect multiple serial ports and TCP ports with only one process. I’ve made no attempt to code for the opposite side of the equation, turning a TCP stream back into a virtual com port because thats not necessary for XTension. Anything XTension can connect to via a local port it can also connect to via a TCP stream.

download:  serial2tcp.zip

(since the code was fairly straightforward I was able to load the source into an older version of the compiler and create a fat binary with both Intel and PPC code for anyone wanting to recycle a really old machine. I’m not entirely sure how far back in OS versions this will run, but it would be worth trying on 10.4 intel or ppc machines.)

download ppc: serial2tcp_ppc.zip

download and unzip. I would recommend placing the serial2tcp folder inside the Applications folder. There is a folder of libraries inside it as well that must remain next to the application regardless where you put it. Then if you’re the kind of person who likes to run things from the command line you can make an alias to your /bin directory.

command line options:

--help   prints out the help
--list    prints out a list of available serial ports on your computer
--share [serial port name] [serial port baud] [tcp port number]

--share is the main entry point for getting it to do anything. Get the serial port name from the --list function, a standard baud rate and a TCP port above 1024 to run it on.

For example to share a CM11a on a remote machine you’d use something like:

/Applications/serial2tcp/serial2tcp --share usberial_FT5434 4800 2000

would connect to an FTDI based usb/serial adaptor with that name, open the port at 4800 baud and share it on port 2000.  If you wish to share more than one port you can use multiple --share parameters. But they must have unique serial port names and TCP port numbers.

The program will allow only 1 connection at a time for any given serial port but will re-listen if a connection goes away. So you should be able to reconnect to it without restarting it or any such thing. It also makes a valiant effort to reconnect to a lost serial port. If someone pulls the USB plug and plugs it back in on the remote machine it will work very hard to reconnect to that port and then reconnect it to the already open TCP stream. If you’re lucky you wont even miss any data. On 10.9 with the latest FTDI drivers I had no trouble with this apart from the garbage data being sent down the serial port making my CM11 freak out until being power cycled. On earlier OS versions though it was not uncommon to get a kernel panic if an open usb/serial adaptor was pulled while in use. So YMMV.

To use it then in XTension just select “remote tcp port” instead of a serial port from the available port popup. Enter the IP address of the computer doing the sharing and the port number you’ve chosen, in the above example 2000. The computer hosting the port should be configured with a static IP address or a reserved DHCP address so that it doesn’t change. If you want to share across the internet you’ll have to be able to create the proper NAT pass throughs to reach it. It’s a server listening for an incoming connection on the port not a client that can make an outgoing connection.

Thats all well and good, but the real value would be in having it launch at computer startup and run no matter who is logged in or if anybody is logged in to the computer. This is possible by setting up a system launchd configuration file for it. The following instructions are for OSX 10.9 and later, but it should work for the last few versions. Earlier than 10.7 and you should verify the proper launchd plist configuration because I believe it has changed since 10.6.

Inside the serial2tcp folder you’ll find a file called “com.sentman.serial2tcp.plist” this is a boilerplate launchd configuration file that you will need to edit for your own use. If you have apple’s dev tools installed then you can use the excellent plist editor, otherwise any text editor can do it but pay attention to the XML structure. Screenshots below are from the plist editor.

The “label” must be unique and should be the same name as the file but without the .plist at the end. You can leave it like it is unless you’re starting multiple instances.

the first program argument must be the link to the program you wish to run, in this case I put it in the Applications folder, but if you put it somewhere else then change that link.

The following parameters are the same as if you were adding them at the command line. In this example I’m sharing usbserial-FTG3LGPX at 57600 baud on port 2000. You’ll want to change those for your own settings. You can add more program arguments if you wish to share more than one port. Just repeat items 1 through 4 with the new info in them.

Once you’ve saved this back you’ll need to place a copy into the system launchd folder which is at /Library/LaunchAgents you can use the command line to get there or the “go to folder” option of the finders “Go” menu and enter that path. It will ask you to enter your password in the finder because this is a system protected folder and you need to run as an administrator to move files in and out of it. Once the file is there you’ll need to edit the owner of the file. It must be owned as root in order to be loaded while nobody is logged in. I could not get this to work from the finder’s file permissions panel and so it must be done from the command line.

Open a terminal window and type:

cd /Library/LaunchAgents


sudo chown root ./com.sentman.serial2tcp.plist

again it will ask you for your password to make sure you’re actually allowed to make a file owned as root.

You can test without rebooting by using the launchctl command from the same command line, type:

sudo launchctl load ./com.sentman.serial2tcp.plist

and you should just get the cursor again if no errors occurred. The program will log it’s output to the system log while running in the background so look there for connect/disconnect errors or other messages. If all went well you should now be able to see it running with the activity manager and connect to the port from XTension and share the device.

This article is cross posted at MacHomeAutomation.com

Sunday, September 14, 2014

xBee network hosted remotely off a Wiznet TCP/Serial board.

Wow, haven’t posted any projects since may 8th?! Most of my effort was spent in playing with the kids over the summer and in porting XTension to Cocoa. We’ve been a carbon app so long because we like to support older operating system versions, indeed we still supported PPC machines up until the most recent build. Thats just got to change, we’re never going to be in the app store or run properly in the sandbox if we don’t get around to leaving some of that behind. The PPC and pre-10.7 builds of XTension will continue to receive bug fixes but are basically done. I’ve been running my house on the cocoa version for almost a month now without difficulty and the ease of doing some important things is just wonderful. Even though the conversion was not at all painless it’s coming along nicely and the UI things I can do now alone make it worth while.

The last few days I’ve been fighting with an xBee breakout board and a Wiznet card trying to build a remotely hosted xBee network. Under most circumstances you can just add more xBee’s in between the area you need to cover and the host machine and connect it directly to the XTension machine, but that isn’t always feasible. So if you have any desire to host an xBee network with the xBee coordinator sitting on an ethernet network somewhere other than where you can reach with a USB cable from your XTension computer here’s the connections you’ll need to make.

Mac Home Automation - Hosting an xBee on a Wiznet card

Thursday, May 8, 2014

New XTension release, v7 build 853

My day job is as a developer of the XTension home automation software for the Macintosh. This new build has a really huge set of new features and I’m really excited about it. It adds support for the Vera interfaces. They are a lot more than just an interface, but not too much more expensive than just a separate ZWave interface. These are the most full featured and most reliable ZWave interface that we support and is certainly my favorite. Though the vera we also gain Insteon support. Technically you can do X10 through the vera as well but it’s so slow as to be unusable and is only outgoing, it can’t receive any X10. For many people the Vera interface would be all the automation that they need and some people wont want to connect it to a computer, but XTension is really for people that have outgrown the capabilities of these devices and want something more.

This version also has a greatly improved web interface. The pages are completely dynamic and while you get simple unit lists for control you can also create custom pages that display any or all of your information. In previous versions this has had trouble on iOS devices, this version fixes those issues and runs great on iOS or other mobile platforms. More mobile templates are on the way so that you’re not looking at a large screen designed interface. You can also create as many different interfaces running on different ports as you like so make a separate one for iOS and another for your tablets and another for your browser.

Friday, January 17, 2014

Important things you need to know when replacing an iPhone 5 battery yourself!

If you’re thinking of replacing your own iPhone 5 battery you can definitely do it, but there are a couple of things I didn’t find documented in any of the shiny take apart videos on the web. If someone had just told me not to pry under the battery next to the SIM card cage i’d be a wealthier man who hadn’t just destroyed his wife’s iPhone as she was heading out the door to work...

I have replaced probably a dozen batteries or failed buzzers or other things in my own and my friends and families iPhones up until this. I’ve had exactly 1 problem in all that time where on my daughters iPhone 4 the whole surface mount battery connector came off the board instead of disconnecting. i was able to repair that with the hot air rework station.

To remove this battery the videos warn that the tape they used is very strong and suggest gently prying around the battery with the spudger. That was an understatement for mine, the tape was cement. And removing the battery without deforming it was impossible as you can see. This is what the battery looked like when I finally got it to come loose.

but it didn’t catch fire or anything. I wish it had occurred to me to use a hair dryer to warm the back of the phone to loosen the adhesive. So thats the first thing I would recommend. Warm it up, not directly on the battery but the back side of the phone.

There are some flat cables that run along the side of the motherboard past the sim card cage. This is where the danger is.

The look solid, but if you stick the spudger down there to get under the battery you will damage the motherboard underneath them.  You can see in this picture that there isn’t even any adhesive in this area, possibly for the exact reason that you can’t pry here. But nobody says not to pry here.

After removing those flat cables it becomes obvious what happened, you can even see the 2 pin head chips that I broke lying on the back of the case. Yes, I managed to break off 2 of them prying the battery out.

I stared at them for some time, even going so far as cleaning the area with some flux and the hotair rework tool but that chip there is obviously damaged, the pads broke off in the chip while 4 others let loose. Wonder why they came off so easily? I am not by any means the only person to have this problem there are many reports on the internet. I still think it’s possible to replace these batteries yourself, but take your time, heat up the sticky tape and DO NOT PRY across from the sim card slot!

the sim card slot is right in the middle where there is no tape on the motherboard side.

Now off to ebay the screen and other still useful parts to try to take some of the edge off the pain of having been an impatient idiot tearing into this poor phone.

Sunday, January 5, 2014

Silencing a Buzzy Cree LED bulb.

The $12 Cree branded bulbs that HD sells are great. They are bright, have good color, they dim and turn on and off reliably with old style pushbutton X10 dimmers but when they are on an old dimmer they buzz something fierce. When on a new style dimmer they are much quieter but I bought some especially to put on X10 dimmers.

This, is a bulb who’s silicone coated envelope was broken in the packaging that I didn’t notice till I got home...

so the fact it has no glass on it probably means it’s even louder (and take note, I dont believe this is an isolated power supply and even if it were it’s probably 70+ volts across all those LED’s in series so you could definitely hurt or kill yourself with this, thats why I’m putting it into a fixture very high up where it doesn’t matter that it’s damaged or what it looks like)

and this:

is what I filled the base with to shut the noisy thing up with. And boy is it quiet now. I dont know what that will do to thermal issues in the power supply, but I just mixed that entire tube and poured it down the top of the bulb letting it coat all the electronics. Once setup it’s as silent as I could wish for.

It really shouldn’t be necessary to break the bulb off one to do this, you could drill a small hole in the metal base, there is room in there probably to do so without hitting anything if you were careful. Probably, but dont try it unless you can see what you’re doing and wish to ruin a lightbulb in a spectacular and potentially dangerous way. And then you could fill it with proper non-conductive thermally conductive potting compound to do the same which would probably then increase the life of the bulb... If it dies a horrible death sooner rather than later I’ll be sure to write it up.

Saturday, November 30, 2013

Comcasts bandwidth notice breaks everything

It was 2 days before the end of the month of November 2013 when I first approached the 300 gig bandwidth limit imposed by Comcast. My daughter has been watching a lot of Dr Who on netflix to try to get caught up for the Day of the Doctor and thats the only thing I can think of that is different than any other month. I’ve never come even remotely close before and certainly do not run any file sharing or other such systems here.

They alert you by sending you an email, but they also start actively filtering your web traffic and inserting code that creates a popup window in every browser session that you try to create. This window will not go away until you log into your comcast account and acknowledge the fact that they are about to start charging you extra.

This altering of the HTML code coming from every server is a huge problem. It will wreck havoc on the “internet of things” and other such devices that happen to communicate on port 80. All of a sudden my internet thermostats were not parsing the fact that they were connected to their service, my phillips hue bridge complained that it had lost internet connectivity, my iDevices would not load any web content at all. The HTML was so broken that I got only a white page with nothing displayed at all.

I finally resorted to rebooting my router and power cycling the hubs that the hue bridge was connected to all without an improvement in what was going on, yet some other things were working so I knew I wasn’t just offline.

I finally logged into my actual desktop computer and got the popup and was able to log into my account and turn it off. But you can’t opt out of the popups entirely, they are “required” for 100% of the usage, though you can turn them on for other amounts.

Net neutrality aside (bandwidth spent watching netflix or hulu counts against my usage, but bandwidth used watching their xfinity app does not, thats cheating Comcast) the implications of their ability to watch not just caching server logs of my html traffic but actually insert code into it, code that is malicious in how bad it is even if it’s purpose is not actually to do harm, is huge. They could alter anything, change what adds are being displayed, silently filter things they dont like. Forcing all port 80 traffic to have this popup inserted even when many devices making such connections dont have the ability to display any such popup and are not sophisticated enough to realize that their JSON or SOAP or XML or other documents have been totally corrupted by Comcast shows a real lack of thought went into this.

Obviously they wish to make sure you know that you’re about to be charged extra so that you can’t get mad at them later when I claim I never got their email. I wish to opt out of your corrupting the HTML data flowing into my home and yet I cannot.

Overall I’ve had very little difficulty with Comcast and the service. It is not overpriced, at least not by the standards of other internet service in America, and it has been reliable. But I will be watching as technology continues to render their privileges of easements to run their wires less important. When other ways of getting connected are available to me I will remember how you broke my house for no good reason and how you filter and insert things into the packets coming into my house.

Wednesday, October 16, 2013

Thoughts upon returning from a short vacation at Disney World

Reviewing the various features and foibles of Disney World is a full time job for an army of bloggers and review sites. Though this is just a single breath in a veritable hurricane of writing on the internet, it is my breath.

We went for just 3 days. My children are 9 and 13 as of this writing and had a wonderful time. It's not necessary or even enjoyable to spend a full week there.  You run out of steam and blister bandaids too quickly. Especially with smaller kids, a couple of days is plenty and take them again in a couple of years instead of blowing all your dough in one huge vacation that they will be too tired to enjoy.

We stayed in the park for the first time this time. Previous visits we've rented a small house somewhere nearby and driven in (and saved THOUSANDS of dollars). Disney runs the best managed and accessible parking lots in world. Do not be afraid to drive in, you will not be delayed. We stayed at the lower tier "resort" The Art Of Animation. I was not initially filled with love and happiness when I first got a look at the industrial big square box buildings with a few lion sketches on the side and a couple of decorations on the endcaps. but they are really OK. The room we had was very nice, with a sofabed and a Murphy bed for the kids in the main room and a separate master bedroom and bath for us to actually close the door and get some sleep. If you're staying in the hotel to make use of "extra magic hours" make sure they actually fit into your schedule. The parks we were visiting never overlapped with an extra magic hour that we could actually visit, so that was a wash.

There is no good way to unload your luggage at these resorts. There are bellhops with trollies at the main checkin but not enough of them and you'll wait for a long time. Or you'll carry your own which is what we did. The parking is very close to some of the buildings, and very far away from others. There is no door to the building facing it either. You pretty much have to walk all the way around to get to the elevators, or use the stairs. Your wristband wont open the doors by the stairs though even if you wanted to use them until you've used it to open your room door which unlocks it for other uses. So you have to walk around to the main entrance which is in the middle of the complex of buildings at least the first time.

I must take a moment and talk about the toilets installed in this hotel. They are obviously air pressure driven and are the loudest flushing toilets I have ever encountered in my life. The first few times you flush them they will make you jump, it takes getting used to. You can also hear every other person in your side of the building when they flush, just as I'm sure everyone could hear you. The volume level is truly impressive. I would also hang onto small children if they are standing nearby when you flush else they be sucked down. These are powerful turbo-charged toilets.

Food service at the hotel was adequate. Disney does everything as good as can possibly be done, and even they can only do just better than passable food service on this scale. The food was not bad, but it was impossible to get your tray and your kids tray definitely from another separate line through checkout and to a table while your food was still warm.

If you buy into the food service plan do the research ahead of time and know what you get and get it before reaching the register. If you're lucky enough to have a cashier that knows what you're entitled to you'll end up going back to get a different drink or another pack of grapes or carrots or a dessert. If you're cashier doesn't know then you just wont get those things that meal. In either case you'll be unhappy.

We also bought the infinitely refillable cups which were a waste of money. They can only be refilled at the resort that you're staying at, there is no point in carrying them to the parks with you as they wont work there. So we bought them and used them the first night we were there. Then the next morning we didn't carry them with us to breakfast because we were going to the parks without returning to the room which is what we then did the rest of our visit. I believe I used them 3 times while we were there. Not worth the money unless you are going to be hanging around the pool at the resort a lot or are willing to walk from your hotel building over to the cafeteria a lot, which can be quite a little walk. After coming back from the parks and taking off my aching shoes the last thing I wanted to do was walk back to the cafeteria to get soda, we just got ice from the ice machine down the hall and had nice cold water.

The cups are interesting from a technological standpoint. They have an RFID chip in the base that has to be programmed or read from the register. There is a reader under every single spigot in the pop dispensers and you have to set it down and wait a heartbeat before you try to fill it. That way there is no black market in used cups as they are programmed only to work while you're there. But nobody really explains how to use them and that you have to set them down, I watched many frustrated people holding them under the spigot and nothing would work till you set them down. Disney is going all RFID for everything and it's not going completely smoothly yet. I'll take the chip out of my cup soon and post some takeapart picts to try to figure out just what the system is based on.

We got "Magic Bands!" which are a cool idea, no more being afraid of losing your card, they easily stay around your wrist (but you'll keep looking at them trying to find the watch face to tell you what time it is, now THAT would be an upgrade to them :) When they say "near" field what they really mean is touching. the range on them is such that if you even press them a little out of perfectly on the front of the sensor they dont work. At least on your hotel door, other readers at the park may be higher power. The absolute best use of this technology is when you combine it with being able to schedule your fast passes on the iPhone app before you even get to the park. This is so fantastic I can't even rave about it enough. Schedule your visits to the 3 biggest rides you want to see before you even leave for the park, or better yet if it's something like soarin do it the day before. At 10am there was already a 2 hour wait in the standby line for soaring the day we were there. We walked right on with a scheduled visit. I really think that the technology is there to schedule more and more of the visits and reduce the walk in line considerably. This would be great, standing in line sucks, just tell me when to come back thats fine. I don't understand why every person in the park isn't doing this.

We visited Blizzard Beach the first day there, then spent that evening at Hollywood Studios because there were only a couple of things we wanted to see there (hello, fast pass!) The second day we spent at epcot and lastly at the Magic Kingdom and that evening did Mickey's not so scary halloween party which is fantastic but you have to book 6 months or more in advance if you want to get in. They sell out regularly now.

At Blizzard Beach the first day we managed to get our first and only minor injury of the trip. My daughter managed to fall off her float on the lazy river and scrape her hand up pretty good trying to hold onto the side. There is an application for nano tech out there somewhere for someone to invest a coating for the bottom and sides of swimming pools so that you have some traction but not so that it rips up your hands and the bottom of your feet while you're playing in it. In any case the very sympathetic life guard handed us a couple of bandaids and we were back on our way. (I think he was glad she hadn't hit her head as he told of witnessing several such events, probably the most dangerous ride at the park because people try to stop themselves and the tubes want to keep going and they flip over into the side of the embankment!)

Epcot has some great stuff too, but it's a LOT more walking than any of the other parks. Epcot though serves beer for just walking around. Which is great in theory, but it means that older "children" end up there behaving like "children" sometimes too which is never pretty.

Our only real negative was trying to find a space around the halloween parade route. Disney has adult fans so rabid that they wont step back 2 feet and let your kids sit on the ground in front of them. So my kids can't see as grownups without any children in tow snap flash pictures in the dark that will never come out of chip and dale dancing to "this is halloween" really people. You could see over my kids, my kids can't see over you. We've had to work around people like this at every parade at Disney that we've ever been too. Thats not to say that we've not met hundreds of perfectly nice and happy to help out or move over people too, but it's the jerks that you remember.

The new Fantasy land in the Magic Kingdom wasn't finished yet, they are still building the new dark ride, I think based on snow white? but the new Little Mermaid rid was up and running and was definitely worth the walk around the back of the new area. The animatronics have made huge leaps and it's amazing stuff. Ariel even had animated hair so that it looked like it was floating around under water. A little bit freaky but just so cool. I felt the ride was a little rushed though, it could have run slower and let us enjoy the details a bit more. It also felt a little sterile to me, there wasn't as much detail to see and it was all very brightly lit. I suppose it will gather details and upgrades over the years, but it's still definitely worth the trip. I think it could have used one more story setting, it went right from Ursela using her voice to woo Eric to the real Ariel's wedding scene. I would have loved to see Eric empaling Ursela on the sailing ship, but I suppose that would be too dark even for a dark ride? In any case, it was a great new ride and you should go on it (unlike the nemo mini-ride they built into the sea, that is totally lame)

The haunted mansion has undergone some updates. Some interactive things to play on in the queue are there now and I think a welcome improvement. The insides as well seem to have been constantly updated and replaced over the years, everything is still there but there is more and more to see. I love it. Same with Pirates which has lost some of it's rather overt movie themeing. Capt Jack is still all over, but the mist screen with the nasty from the movie right before the initial fall is gone (or wasn't working when we were there) making it more like it was prior which I liked better.

Disney theme parks are awesome. Take your children for a couple of days, not when they are too little or they wont like the dark rides and loud noises. (bring earplugs for anyone who might be startled! It makes a huge difference in their enjoyment) Take them back to the hotel in the heat of the afternoon and come back in the evening after you've rested up. Even if you hate corporate Disney and the stupid that is the Disney Channel and the stupid that is Disney sponsored tween targeted rock and roll. The parks are wonderful.