Skip to content

Instantly share code, notes, and snippets.

@maxgibbons
Created August 24, 2016 18:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save maxgibbons/db3dd583a634e29611a1ab511ec19003 to your computer and use it in GitHub Desktop.
Save maxgibbons/db3dd583a634e29611a1ab511ec19003 to your computer and use it in GitHub Desktop.
Parsers.py Additon
#------------------------------------------------------------------------------
# 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