SBD Message Flow
This documents the message flow and formats that for SBD messages that are sent to the tracking database via email. Here are the high-level steps that happen when an SBD message is sent to driftertrack@mbari.org:
- Email arrives through mbarimail.mbari.org.
- I believe the email actually gets directed to the driftermail account on pismo, not driftertrack.
- Somehow, that message makes it to the driftertrack account when then gets handed off to the .forward script in the
/home/driftertrackdirectory. The output of that script gets piped to the~/logs/dotForward.logfile. - The script pipes the email message to the
/home/driftertrack/dev/MBARItracking/scripts/drifterMessage.pyscript which logs all of it’s activity to the~/logs/drifterMessage.logfile. - drifterMessage.py tries to extract any attachment to the
~/mailMessagesdirectory. - If there wasn’t an attachment it goes through a series of somewhat ad hoc heuristics to determine what kind of drifter it is and to what function should be called to parse it:
- If the name of the drifter starts with
noreply, it is handed off to a function namedprocessSPOTMessagein thedrifter.pyscript- TODO - document these steps
- If the name starts with
sensbot, it is handed off to a function namedprocessComtechMessagein thedrifter.pyscript- TODO - document these steps
- If the name starts with
solo, it is handed off to a function namedprocessLSTMessagein thedrifter.pyscript.- TODO - document these steps
- If none of the above apply, it is handed off to a function named
processSubjectMessagein thedrifter.pyscript.- TODO - document these steps
- If the name of the drifter starts with
- If there is an attachment:
- The script tries to find the IMEI number in the attachment
- If it can’t, it’s handed off to the
processMessagefunction in thedrifter.pyscript- TODO - document these steps
- If it does find an IMEI number, it tries to look up a corresponding name in the imeiDict. If it doesn’t find a name, it basically logs the messages and ignores it
- If it finds an name associated with the IMEI, it will call the proper function based on the name. At the time of this writing:
- Moe ->
processESPSBDMessage- TODO - document these steps
- mCPF001 or Faucon ->
processCPFSBDMessage- This function first opens the sbd attachment and is expecting a specific format that was defined with Gene Massion and Brent Jones. Depending on which format is specified, the locations of the different values are in different columns. There is a dictionary in this function that is used to lookup which values are in which columns.
- First, it simply reads the line from the attachment and appends it to the platformName_data file on a local file and then copies this file to the Tracking share in the drifters directory.
- The script then tries to parse the epoch seconds, lat and lon from the line read from the file.
- If the epoch seconds were parsed correctly, the script then writes position to the platformName_pos file and then copies that file to the Tracking share in the drifters directory.
- The script then inserts the data into the tracking database
- The script then publishes the data to the AMQP drifters exchange in the form of a string that looks like
drifter,platformName,epochSeconds,lat,lon,drifter.py,mmsi,imei,dateString
- Moe ->
Note
To have a platform name associated with an IMEI number you have to edit the drifterMessage.py script and add the association to the imeiDict dictionary.
Note
If you are sending SBDs and you don’t have a name associated with the IMEI number in the drifterMessage.py script, it will be ignored.
Note
At the time of this writing, if somebody wanted to have their SBD message processed by this script, they need to send us the IMEI number and the name they want associated with it and we would add it to the drifterMessage.py script in the imeiDict. Their SBD attachment should be of the following form and emailed to driftertrack@mbari.org
2016-09-26T14:02:17Z,3654.01485,N,12220.51817,W,SBDI Msg Num:1,SQ=0,moStat=0,1of 6,NaN,NaN,False,5452,3272,836.1,UBX,00,140150.00,3654.01485,N,12220.51817,W,0.000,G3,3.3,4.7,0.849,231.29,0.134,,1.66,2.61,1.93,8,0,0*7A