Created
August 24, 2016 18:57
-
-
Save maxgibbons/db3dd583a634e29611a1ab511ec19003 to your computer and use it in GitHub Desktop.
Parsers.py Additon
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#------------------------------------------------------------------------------ | |
# Temp/Humidity Arduino | |
# APP_INTF7 Application UART A_UART_RX J207 pin 7 | |
# Sample of a serial-based Arduino-to-rACM setup. Add additional sensor inputs | |
# under 'expectedSensors'. Since we're sending all sensor data to rACM as a single | |
# serial string all sensorIds are '6' and sensorType is '0xFFF'. sensorName should | |
# correspond with your M2X stream names. | |
#------------------------------------------------------------------------------ | |
def parser_serial_m2x(raw_hex): | |
expectedSensors = [{'sensorId': 6, 'sensorType':0xFFF, 'sensorName':'humidity',\ | |
'sensorDesc':'Relative Humidity, Arduino'}, | |
{'sensorId': 6, 'sensorType':0xFFF, 'sensorName':'temp_f',\ | |
'sensorDesc':'Temperature (deg F), Arduino'}] | |
expectedAlarmTypes = [] # no alarms from this device | |
msg = RacmUlMssg(raw_hex, expectedSensors, expectedAlarmTypes) | |
if msg.getStatus() == 'OK': | |
if msg.getMsgType() == 'Alarm': | |
return(msg.getMsgType(), msg.getAlarmData()) | |
else: | |
return(msg.getMsgType(), msg.getData()) | |
else: | |
# Debug | |
print 'ERROR: ', msg.getError() | |
print 'raw_hex = ', raw_hex | |
return('ERROR','') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment