Parsing Misterhouse Serial Data

The sensors transmit data in the form “Address,Port,Value” A typical input would be “A1,T1,30.0″ for module 1, temperature sensor 1, and 30 deg C.

In this case only temp data is read by this. split is used to segment the three elements, the temperature is converted to Fahrenheit, and the result stored in a hash.

$xbee_serial = new Serial_Item(undef, undef, 'serial1');
if (my $data = said $xbee_serial)
	my @values = split(',', $data);
	my $temp = $values[2] * 9 / 5 + 32;
	$xbee_data{ $values[0].$values[1] } = $temp;