Skip to content

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:

  1. Email arrives through mbarimail.mbari.org.
  2. I believe the email actually gets directed to the driftermail account on pismo, not driftertrack.
  3. Somehow, that message makes it to the driftertrack account when then gets handed off to the .forward script in the /home/driftertrack directory. The output of that script gets piped to the ~/logs/dotForward.log file.
  4. The script pipes the email message to the /home/driftertrack/dev/MBARItracking/scripts/drifterMessage.py script which logs all of it’s activity to the ~/logs/drifterMessage.log file.
  5. drifterMessage.py tries to extract any attachment to the ~/mailMessages directory.
  6. 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:
    1. If the name of the drifter starts with noreply, it is handed off to a function named processSPOTMessage in the drifter.py script
      • TODO - document these steps
    2. If the name starts with sensbot, it is handed off to a function named processComtechMessage in the drifter.py script
      • TODO - document these steps
    3. If the name starts with solo, it is handed off to a function named processLSTMessage in the drifter.py script.
      • TODO - document these steps
    4. If none of the above apply, it is handed off to a function named processSubjectMessage in the drifter.py script.
      • TODO - document these steps
  7. If there is an attachment:
    1. The script tries to find the IMEI number in the attachment
    2. If it can’t, it’s handed off to the processMessage function in the drifter.py script
      • TODO - document these steps
    3. 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
    4. 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:
      1. Moe -> processESPSBDMessage
        • TODO - document these steps
      2. mCPF001 or Faucon -> processCPFSBDMessage
        1. 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.
        2. 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.
        3. The script then tries to parse the epoch seconds, lat and lon from the line read from the file.
        4. 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.
        5. The script then inserts the data into the tracking database
        6. 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

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