Using Serial Devices in FreeBSD / How to set a terminal baud rate

Posted by Benjamin Close on January 8, 2010 under FreeBSD, UniSA | Be the First to Comment

Recently I was working on a php command line program that required access to a serial port.

Initially developed under Linux the program was then shifted to it’s permanent location on a FreeBSD server. This is where we first started having problems. Initially we discovered the server didn’t have a native serial port. We fixed this using a USB to serial converter/dongle (FTDI Chipset). This was fine as FreeBSD has the ufdti kernel module. Upon loading the module new devices appears in /dev

crw-rw----  1 uucp  dialer    0, 157 Oct  6 08:39 /dev/cuaU0
crw-rw----  1 uucp  dialer    0, 158 Oct  6 08:39 /dev/cuaU0.init
crw-rw----  1 uucp  dialer    0, 159 Oct  6 08:39 /dev/cuaU0.lock
crw-rw-rw-  1 root  wheel     0, 154 Jan  8 10:50 /dev/ttyU0
crw-------  1 root  wheel     0, 155 Oct  6 08:39 /dev/ttyU0.init
crw-------  1 root  wheel     0, 156 Oct  6 08:39 /dev/ttyU0.lock

We attempted to connect to our device using screen (screen /dev/ttyU0 115200) and everything worked as expected. We could send AT commands to the device all ok.
We then stopped screen and ran our php program. It ended up hanging on a fgets call to the serial port. This is really strange we though.
Next we queried the port to find out what baud rate it was set at:

>stty -f /dev/ttyu0
speed 9600 baud;
lflags: echoe echoke echoctl
oflags: tab0
cflags: cs8 -parenb

Strange we thought as we’d just connected with screen at 115200. Under linux we use screen to set the baud rate, all other programs accessing the port use the port at 115200. So what had set it back to 9600 baud?
We tried to use stty to set the speed:

>stty -f /dev/ttyU0 speed 115200
>stty -f /dev/ttyu0
speed 9600 baud;
lflags: echoe echoke echoctl
oflags: tab0
cflags: cs8 -parenb

What on earth was happening? We set the speed to 115200 but directly quering the port again indicated it was still at 9600 baud? At this point we were perplexed.
Eventually we found the solution. The newer FreeBSD terminal drivers provide the *.init devices, in this case /dev/ttyU0.init . These devices indicate the terminal settings to be applied to the terminal when the device is closed. Whilst Linux leaves the device in the same state the last program put the port into, FreeBSD restores the terminals state to what ever is specified in the init file. So a quick command:

> stty -f /dev/ttyU0.init -icanon -isig -echo echoe echok echoke echoctl -icrnl -ixany -imaxbel ignpar -opost -onlcr -oxtabs cs8 -parenb -hupcl clocal

And then to check:

> stty -f /dev/ttyU0
speed 115200 baud;
lflags: -icanon -isig -echo echoe echok echoke echoctl
iflags: -icrnl -ixany -imaxbel ignpar
oflags: -opost -onlcr -oxtabs
cflags: cs8 -parenb -hupcl clocal

Excellent. The terminal was now configured exactly how we wanted. We ran the program and it worked like a charm!

House construction Progresses – We’re past Lockup – Solar System is installed

Posted by Benjamin Close on December 17, 2009 under Country Living | Be the First to Comment

With Christmas just around the corner it’s time for another house update. Things have progressed quite a bit since the last update but also a lot slower. The house has finally reached lockup and  hence we only get to see what’s happening when trades men are around.

Format Homes have continued working on the house and each week a little bit more has been done. Since the last update the following has happened:

  • Gyprock has been completed
  • Doors have been installed
  • Cornus has been put up in all rooms except the bathrooms (we’re having ceiling high tiles)
  • The Bath has been installed
  • The showers have been water proofed
  • The screens have been put on the doors & windows
  • Tiles have been delivered and begun to be installed
  • The bricks have been cleaned
  • The kitchen has been installed
  • The Bathroom & Ensuite Vanity has been installed
  • The linen press has been installed
  • Eaves have been put up
  • The Gable has been capped

All of this happened over the few weeks since the last update. Sadly it doesn’t look like we’ll be in by Christmas. This seems to be due to the Tiler who, whilst doing a good job, is also quite slow.

On the flip side, Solaris has almost fully installed our 3.3kw Solar system. Including batteries, inverter, regulator and panels. It took the guys a week to install and they did a great job at making it work, look good and were very professional.

Below is some photos of the progress of both the house and the solar system installation.

Solar Hot Water – Evacuated Tubes – Apricus vs Hills

Posted by Benjamin Close on November 18, 2009 under Country Living | Read the First Comment

Solar-Evacuated-Tube-Collector-Heatpipe

In building our new house we decided to install a solar hot water system. The reasons for this was simple. We have no mains electricity and only LPG bottled gas. Hence continually heating water would have cost us a lot. Solar hot water on the other hand has an upfront cost but substantially reduces the ongoing cost. Only having rain water and being in a frost region, we quickly decided on evacuated tubes rather than flat panel collectors. Not only is it safer for us (no glycol to leak into our water supply) but there is also an added benefit of better solar performance.

With the decision to use evacuated tubes made, it was now a matter of what brand. This is where the real issues began.
In Australia there is two main contenders for evaculated tube hot water system. These are Apricus and Hills. So began the investigation as to which is better. The Apricus system is significantly cheaper than the Hills. The Hills system is a ‘name brand quality’ company. A little more research finds that both companies are actually Australian (Apricus Australia) and the collectors are all imported anyway.

Not believing in hype about name brands the investigation began into the real differences of each system. It turns out there is quite a few. The below table lists the differences and a comment related to each.

Update: 20091124 – Chris Taylor Director of Apricus Australia has provided updated information to each comment – see below in red

Difference Hills Apricus Comment
Heat Exchanger/Manifold Warranty 10 Year 15 Year If a company is willing to warrant a component for 5 years more, it is probably of higher quality

Apricus is a global company with its own manufacturing operation.   It exports to more than 30 countries and has offices in the US and Europe. Hills are simply buying OEM from a Chinese company with no direct control over the manufacturing, management, working conditions adherence to labor laws, pollution control or quality control. Apricus is fully a ISO9001:2008 certified operation and audited 3 -4 times a year from 3 party auditors from Australia, Germany, USA and China.  Michael Humphreys, an Australian and the founder and CEO of Apricus is based full time in China managing the manufacturing facility.

Heat Exchanger Weld Joints 64 Welds 6 Welds Looking at both systems at a local ‘home expo’ this point is quite clear. Hills weld either side of the heat exchanger, Apricus only weld in a few places. The reason for this is probably due to the manifold setup. In the Apricus system the tube sits between two copper pipes. In the Hills there is weld joints either side of each collector. Personally, I believe less welds are stronger as you’ve not cut the original pipe in the first place!

The Apricus header was specifically designed in that way to minimise welds which are potential failure points.  The Apricus design is NOT less efficient in terms of heat transfer as we have a large head size which provides plenty of contact surface area.  The heat pipe to header connection is not a bottle-neck to the system efficiency.

Steam Relieve Valve Supplied
Caleffi 250 series
Not Supplied The steam relief valve was certainly an interesting point when comparing the differences. Hills use the Caleffi series valves (http://www.caleffi.com/en_IT/Technical_brochures/01133/01133.pdf).
As noted in http://www.ata.org.au/forums/topic/apricus-or-hills-evacuated-tube-solar-hw-system these valves are designed to work with gycol and are not Potable (drinkable) water rated.
The other interesting point is the the maximum temperature rating of the steam valve. Max temp is 180 degrees. Pure water turns to steam at 100 degrees. However it’s under pressure in the collector. Hence in order for steam to form it must be hotter than 100 degrees. On a hot day I can understand 180 degrees being met quite easily. This as indicated in the link can melt the steam valve.

1. They are not potable water rated.
2. They will fail due to scale buildup in the fine hole.
3. They will melt as the collector can reach 190oC
4. They will dump as much as 20L per day in steam, a fact that Apricus is raising with Australian Standards as system are not allowed to dump excessive volumes of water as a means of dissipating excess heat as outlined in AS2712:2007 “no-load” clause 7.4.3 and test methodology in Appendix F.

Rubber Holder vs Plastic Holder for evacuated tube end Plastic Rubber I noticed this at a recent trade show. I do agree the plastic of the hill system will last longer. Though it’s not worth the significant cost difference. – You could even buy the boots from Hills and use them with Apricus!

Apricus uses HTV Silicone Rubber because it is FAR SUPERIOR to any plastic in terms of UV resistance.  It is a more expensive material choice than plastic, almost double the cost in fact.   I would be interested to see a third party report showing that the plastic used by Hills will last the equivalent of 10 years UV exposure without significant loss of structural strength and function

Flow Rate Limiter Supplied Not Supplied As discussed with a representative from Energymatters hills use a flow rate limiter where as Apricus do not. The rep. indicated the limiter was an important part of the system to make sure that the full efficiency was obtained from the collector. This didn’t sit well with me. Why when you have a pump moving water around would you want to slow it down? This puts pressure on the pump and makes it more likely to fail. Further investigation indicates it is due to the manifold design. The hills manifold is designed to hold 1.7l of water at a time, the apricus only 0.7l (30 tubes). Hence Hills needs the flow limiter as there’s more water to heat at any time. Apricus on the other hand is putting the same heat into less water, hence don’t need the limiter.

1. Until just the last couple of week the flow meter were NOT watermarked hence Apricus has not been allowing their use as we adhere strictly to the Australia Standards.   Now they are finally certified Apricus is investigating making them a standard part of the system.
2. It should not be used to SLOW the water but rather to allow the actual flow rate to be observed and if too slow a faster speed on the pump can be chosen (if using a 3 speed pump), Apricus would not suggest restricting the flow rate by more than 25% otherwise it is effectively wasting electricity by artificially increasing the head pressure of the solar loop and forcing the pump to run longer each day.

Circulating Pump ? Bianco three speed pump Both pumps have a 1 year warranty. The Apricus pump is stainless steel, the Hills pump is unknown.

The Apricus pump is a brass body pump, 3 speed.   The Hills would also be brass or bronze but I think single speed.  I don’t know of anybody using a SS body pump in the market.

Tank Choice Stainless Steel Stainless Steel or Glass Lined As from: http://www.ata.org.au/forums/topic/apricus-or-hills-evacuated-tube-solar-hw-system

3. The tanks used in the market by Apricus are Everlast (stainless steel) or Aquamax.. Hills use Everlast tanks too. They are both made in Australia.

Stainless steel is a quality choice but more expensive. It is not suitable for all areas those as certain type of water, particularly bore, will quickly corrode stainless steel. The warranty policy of Everlast provides details of that.

Vitreous enamel (aka glass lined) tanks don’t generally last as long as SS tanks as they are protected by a sacrificial magnesium anode which corrodes instead of the steel. The problem is that hardly anybody actually replaces the anode, which you should do once every 3-4 years (depending on water quality). If you DO replace the anode the tank could last 10+ years.

Since the most likly point of failure in an evacuated tube system is the Heat Exchanger/Manifold the Apricus system does sound more promising.  This ironically is the one component that Hills don’t seem to trust as much as Apricus. Clearly indicated by the 5 year difference in warranty.

Bricks, Roof, Plumbing, Electrics, Insulation and now Gyprock!

Posted by Benjamin Close on October 20, 2009 under Country Living | 4 Comments to Read

Wow, how time flies! It’s been almost 2 months since I last wrote about the progress of our house and lots has happened in that time. Our supervisor has been absolutely awsome, great to talk too, willing to listen and also willing to deal with concerns that we have had. Actually most people that have worked on the house have been great.

For instance the bricky really looked out for us. First a little background. We’ve no mains water hence we’ve only had water available for the bricky via a 1000 litre tank. Initially we didn’t even have a pump hence it was all gravity fed. This gave the bricky great fun trying to clean his tools – he had to fill buckets up and use them to make his mix. However, he didn’t complain, just went about his job. He mentioned he would need pressurised water for his saw but that would be later down the track. We are also madly trying to collect rain so that we have water when we move in. Hence once the roof was on we put some temporary down pipes in place. These led into the tank.

One morning I noticed a piece of steel proped between the shed and the tanks. After talking to the bricky about this it turned out the previous day when it had been raining, the downpipe had shifted in the wind, spilling water everywhere. After one attempt to put it back in position – where he got covered by water, he grabbed a spare piece of steel and wedged the pipe back in place.

There was many little things like this that really made having the bricky working on the house great. He also did a fantastic job with the bricks!

The roofing guys (that I never met) took a little longer than expected to get the roof on. They put it up in stages, with the rain being an issue as well as the wind (we’re in category 3 wind zone). Each stage it went up we were trying to collect more and more water.

The sparky’s took 1 day to get the house ready. Very neatly done and all spot on the first time.

The plumber on the other hand really had no idea. We requested a hot water plumbing loop but this was not done.. well not properly. 1 call to the super and he said he would take care of it. Which he did. The plumber came out again and the setup got even worse – certainy not the super’s fault though. Another call to the super and this time he got me to meet the plumber on site. After quite a few attempts of explaining the concept he (and his super) finally caught on and got this done correctly.

To Format Home’s credit, the issues with the plumber were the contracting service that they use. Something that they have indicated they might re-consider in the future. The whole time the super was excellent in dealing with the issue.

So now it’s a new week and everything is happening. Monday the bricky finished – sad to see him go. The gyprock and the insulation was also delivered. Mid Monday, the insulation got put up (Walls anyway). Today (Tuesday) the gyprock started going up and within the day, all the bedrooms are done! Tomorrow the plaster starts.

Check out the progress shots of things happening….

Mitchell Zachary Close Is Born – Bub arrives early!

Posted by Benjamin Close on September 21, 2009 under Country Living | Be the First to Comment

As of 16th Of September 2009, at 5.36pm Carly and I are proud parents of little Mitchell Zachary Close. Born 37.2 weeks, 2.69kg (5 lb, 15oz) at the North Easter Community Hospital. Our lives have now changed for ever – in the best possible way! Checkout some of the photos we have of Mitchell:

5 weeks before Bub arrives!

Posted by Benjamin Close on August 27, 2009 under Life | Be the First to Comment

Wow how time flies! Would you believe our little bub is due in only 5 weeks time (4th October). Carly can feel the little one kick lots more – sometimes even wonders if they are going to be a boxer! Below you can see the happy Mum to be – looking fantastic!

Carly with 5 weeks to go

Carly with 5 weeks to go

The frame complete

Posted by Benjamin Close on under Country Living | Read the First Comment

The frame is now up! As of today the frame is finished an the windows are starting to go in, starting with the bay window at the front.

The Shed, Septic & Frames Take Shape

Posted by Benjamin Close on August 18, 2009 under Country Living | Be the First to Comment

After a couple weeks with little happening, it seems things are finally starting to pick up. Last week saw the shed start to go up, and the house being rubbled and the septic tank going in. It’s nice to finally have the rubble in place. We’ve been told quite a few times it’s too wet for anything to happen on the house. Now there is no excuse! Granted it’s still a little wet at the front of the house – the clay takes a while to dry out. With rubble over the top of the clay it’s at least workable.

So starting this week things really started happening. Monday had half the steel for the house walls going up, Tuesday found the rest of the walls going up and the shed getting it’s capping and floor poured.

It was interesting talking to the guy’s putting up the house walls. Apparently due to the wind speed in our area (51m/s) the amount of dynabolts that get put in almost triple. Every stud gets bolted as apposed to one dynabolt every 1200mm. The house is starting to look great. Walking through it Tuesday night, it’s nice to see what was designed on paper really working out the way that was imagined.

In regards to the shed – We have a shed! Apart from the tanks it’s the first main structure on the block – at least that is complete. Roof, walls, floor, doors! After the weekend there is even some temporary plumbing in place to collect some water. (We even collected 5 mm’s worth on Sunday night). Enough to at least make it to the tap level in the tank.

So for now, check out the photos below about how things are looking.

VMWare woes with DISK IO & Possible Solution

Posted by Benjamin Close on August 12, 2009 under ClearChain, Computers | Be the First to Comment

Recently the server hosting clearchain.com (aka Leo) has been having disk io errors. This has had me quite perplexed. You see Leo is a virtual machine running on redundant hardware as part of an VMWare ESX cluster. Hence whilst I can understand slow performance and delayed access at some times, disk IO’s don’t make sense.

You see Leo has a virtual disk. This virtual disk is provided by software running on the ESX host. The only way for disk IO errors are if the physical media that it runs on has errors or something inbetween the physical media and the machine providing the virtual disk has errors.  I’ve been assure by our hosting provider (Hmon – A great little company) that neither of these situations have happened.

Despite that disk errors (Virtual in this case) have been occurring:

Aug 11 02:00:49 leo root: ZFS: vdev I/O failure, zpool=tank path=/dev/da0s1e offset=103662968832 size=16384 error=5
Aug 11 02:00:49 leo root: ZFS: vdev I/O failure, zpool=tank path=/dev/da0s1e offset=103662968832 size=8192 error=5
Aug 11 02:00:49 leo root: ZFS: vdev I/O failure, zpool=tank path=/dev/da0s1e offset=103662977024 size=8192 error=5
Aug 11 02:00:49 leo root: ZFS: vdev I/O failure, zpool=tank path=/dev/da0s1e offset=169141542912 size=98304 error=5
Aug 11 02:00:49 leo root: ZFS: vdev I/O failure, zpool=tank path=/dev/da0s1e offset=169141542912 size=1024 error=5
Aug 11 02:00:49 leo root: ZFS: vdev I/O failure, zpool=tank path=/dev/da0s1e offset=169141543936 size=1024 error=5
Aug 11 02:00:49 leo root: ZFS: vdev I/O failure, zpool=tank path=/dev/da0s1e offset=169141544960 size=1024 error=5
Aug 11 02:00:49 leo root: ZFS: vdev I/O failure, zpool=tank path=/dev/da0s1e offset=169141545984 size=1024 error=5
Aug 11 02:00:49 leo root: ZFS: vdev I/O failure, zpool=tank path=/dev/da0s1e offset=169141547008 size=1024 error=5
Aug 11 02:00:49 leo root: ZFS: vdev I/O failure, zpool=tank path=/dev/da0s1e offset=169141548032 size=1024 error=5

A little perplexed I started to try and work out why. Then I hit the article: http://virtualgeek.typepad.com/virtual_geek/2009/06/vmware-io-queues-micro-bursting-and-multipathing.html
and it all made sense. The problem is Unix machines are much harder on disks sending many more requests to them than a standard windows machine. Looking at the logs it’s clear there is lots of requests happening very rapidly. Whilst the disk IO (iscsi backplanes in this case) can keep up, the burst rate of requests (IO’s per second) appears to be too low. Hence vmware panics as it can’t service the requests via the vscsi queues quick enough and hence the virtual machine (Leo in this case) gets told there is a disk error. All the while the physical disks in the virtual cluster haven’t even been stressing.

Whilst this is currently only a theory I have, I’ve asked Hmon to look into increasing the vscsi queues to help deal with the burst rate IO better.