Msb-server: Difference between revisions

From University of Washington - Ubicomp Research Page
Jump to navigationJump to search
No edit summary
 
No edit summary
 
(2 intermediate revisions by the same user not shown)
Line 60: Line 60:
</pre>
</pre>
</ul>
</ul>
</ul>
== msb.ini ==
<ul>
msb.ini specifies which serial port the MSB is attached to, the serial port settings, the <b>schedule</b>, and other miscellaneous options.
The schedule is set of sampling rates for each sensor, in number of samples per ten seconds. The microphone sampling rate is the one exception; it's specified in the number of samples per second. Setting a sensor to 0 samples per ten seconds causes the sensor to turn off. Each sensor has its own maximum sampling rate (and some have minimum sampling rates), but due to the tight timing constraints of the MSB, the sampling rate of one sensor can affect many others. To create a schedule that will work on the MSB, use [http://ubicomp.cs.washington.edu/MSB/MSB_V1_1/MSB_Schedule_Calc_v1_1.xls this Excel spreadsheet]. The MSB will reject any schedule it cannot meet and return the best schedule it can handle.
The available options you can set in msb.ini are:
{| class="wikitable" style="text-align:center"
!! | Option || Description
|-
| SERIAL_DEVICE || Specifies the serial port the MSB is attached to. This should be /dev/ttyS0 on the MSP.
|-
| BAUD_RATE || The baud rate the MSB communicates at. This should be 921600.
|-
| HARDWARE_FLOW_CONTROL || If set to 1, enables hardware flow control. This should be enabled.
|-
| SOFTWARE_FLOW_CONTROL || If set to 1, enables software flow control. This should <b>not</b> be set.
|-
| SCHEDULE_INTERRUPT_COUNT || The number of timer interrupts per ten seconds on the MSB. This is effectively the upper sampling rate of every sensor except the microphone. This is usually set to maximum allowed value, 5120.
|-
| SCHEDULE_AMB_LIGHT || The number of ambient light sensor samples per ten seconds. This is usually set to 1280.
|-
| SCHEDULE_COMPASS || The number of compass samples per ten seconds. This should be set to 0 on all modern MSBs.
|-
| SCHEDULE_BAROMETER || The number of barometer samples per ten seconds. This is usually set to 71.
|-
| SCHEDULE_DALS || The number of dual ambient light sensor samples per ten seconds. This is usually set to 30.
|-
| SCHEDULE_HUMIDITY || The number of humidity sensor samples per ten seconds. This is usually set to 10.
|-
| SCHEDULE_POWER || The bit field of power-saving options. For a description of what each bit means, see [[MSB2_Firmware#Power_Control_Bits|Power Control Bits]]. <b>Note:</b> Enabling power-saving for a sensor will reduce the maximum sampling rate of that sensor.
|-
| MIC_GAIN || The microphone gain. 0 is the least gain, and 255 is the most gain. This is usually set to 128.
|-
| LOG_FILE || Specifies the initial log file name used when writing a log. Not used with [[Logger|logger]].
|-
| LOG_TYPE || Sets the log type. This can either be "uwar" or "stream". Not used with [[Logger|logger]].
|-
| LOG_START || If set to 1, enables log writing. Not used with [[Logger|logger]].
|-
| LOG_MAX_TIME || Maximum elapsed time per log file, in seconds. Not used with [[Logger|logger]].
|-
| LOG_MAX_TIME || Maximum log file size, in kilobytes. Not used with [[Logger|logger]].
|-
| EXEC_LOG_FILE || Specifies the initial execution log file name when writing an execution log (the output that's sent to the console).
|-
| EXEC_LOG_START || If set to 1, writes an execution log. Not normally used, except when debugging.
|-
| USE_IPC || If set to 1, enables IPC. By itself, this configures the msb-server to listen for all IPC messages and publish the schedule and calibration. This is usually enabled.
|-
| IPC_PUBLISH_DATA || If set to 1, publishes sensor data over IPC. Not normally set.
|-
| IPC_PUBLISH_RAW || If set to 1, publishes raw sensor data over IPC. Not normally set.
|-
| IPC_PUBLISH_STREAM || If set to 1, publishes the raw serial port data stream over IPC. Not normally set.
|-
| IPC_PUBLISH_MIC || If set to 1, publishes microphone samples over IPC. Not normally set.
|-
| SHM_PUBLISH_STREAM || If set to 1, publishes the raw serial port data stream over shared memory. This should be set to 1 if using [[Logger|logger]].
|-
| USE_RTC || If set to 1, enables reading and setting of the MSB's real-time clock. Not normally set.
|-
| CHANGE_SYSTEM_TIME || If set to 1, sets the system clock to the MSB's real-time clock. Not normally set.
|-
| PACKET_INTERVAL_IN_MS || Time interval between IPC publications. Not normally set, but defaults to 100 internally.
|-
| GPS_ENABLE || If set to 1, drives the GPS enable line high (pin 3 of P1).
|-
| ACCEL_RANGE || Sets the accelerometer range to either +/-2g or +/-6g. Valid options are 2 or 6. Defaults to 2.
|}
</ul>
</ul>
== example output ==
== example output ==
<ul>
<ul>
Typically the msb-server will output something similar to the following. Where the final recieved stats will continue until the program is terminated or an error occurs.
Typically the msb-server will output something similar to the following. Where the final received stats will continue until the program is terminated or an error occurs.
<pre>
<pre>
./msb-server -ini ./msb.ini -ipc-publish-data
./msb-server -ini ./msb.ini -ipc-publish-data

Latest revision as of 00:37, 14 August 2007

msb-server

The msb-server is a program which interfaces with the MSB via the serial port and handles logging of uwar files and transmission of the sensor data over IPC and other shared memory mechanisms. msb-server was written by Dirk Hähnel of Intel Research Seattle.

usage

    Typical Usage

      msb-server -ini msb.ini
      

      where msb.ini will typically contain:

      #Desktops should use the USB device
      #SERIAL_DEVICE 			/dev/ttyUSB1
      #the iMote2 uses ttyS0 only
      SERIAL_DEVICE 			/dev/ttyS0
      BAUD_RATE			      921600
      HARDWARE_FLOW_CONTROL		0
      SOFTWARE_FLOW_CONTROL		0
      USE_RTC                       1
      SCHEDULE_INTERRUPT_COUNT      5120
      SCHEDULE_MIC                 8192
      SCHEDULE_ACCELEROMETER        5120
      SCHEDULE_AMB_LIGHT            2560
      SCHEDULE_BAROMETER              71
      SCHEDULE_DALS                   30
      SCHEDULE_HUMIDITY               10
      SCHEDULE_POWER                   0
      MIC_GAIN                        64
      
      LOG_FILE			 test.uwar
      LOG_START			 1
      

    Available Commands

      In addition the msb-server also supports the following switch commands:
      -ipc-publish-data    publish the converted data via IPC
      -ipc-publish-raw     publish the raw sensor data via IPC
      -ipc-publish-stream  stream serial data via ipc
      -shm-publish-stream  stream serial data via shared memory
      -ipc-publish-mic     publish microphone packets
      -sync-rtc
      -show-rtc
      -set-rtc
      -use-rtc
      -log        specify a file to log data to, see -max-size and -max-time for log rotation settings
      -log-type   specify the type of data to log:
        uwar      serial data is stored as packets in a uwar file
        stream    serial data is written directly to a file
      -max-size   maximum size of the uwar file before rotating the log file (in kilobytes)
      -max-time   maximum time between file rotations
      

msb.ini

    msb.ini specifies which serial port the MSB is attached to, the serial port settings, the schedule, and other miscellaneous options. The schedule is set of sampling rates for each sensor, in number of samples per ten seconds. The microphone sampling rate is the one exception; it's specified in the number of samples per second. Setting a sensor to 0 samples per ten seconds causes the sensor to turn off. Each sensor has its own maximum sampling rate (and some have minimum sampling rates), but due to the tight timing constraints of the MSB, the sampling rate of one sensor can affect many others. To create a schedule that will work on the MSB, use this Excel spreadsheet. The MSB will reject any schedule it cannot meet and return the best schedule it can handle. The available options you can set in msb.ini are:
    Option Description
    SERIAL_DEVICE Specifies the serial port the MSB is attached to. This should be /dev/ttyS0 on the MSP.
    BAUD_RATE The baud rate the MSB communicates at. This should be 921600.
    HARDWARE_FLOW_CONTROL If set to 1, enables hardware flow control. This should be enabled.
    SOFTWARE_FLOW_CONTROL If set to 1, enables software flow control. This should not be set.
    SCHEDULE_INTERRUPT_COUNT The number of timer interrupts per ten seconds on the MSB. This is effectively the upper sampling rate of every sensor except the microphone. This is usually set to maximum allowed value, 5120.
    SCHEDULE_AMB_LIGHT The number of ambient light sensor samples per ten seconds. This is usually set to 1280.
    SCHEDULE_COMPASS The number of compass samples per ten seconds. This should be set to 0 on all modern MSBs.
    SCHEDULE_BAROMETER The number of barometer samples per ten seconds. This is usually set to 71.
    SCHEDULE_DALS The number of dual ambient light sensor samples per ten seconds. This is usually set to 30.
    SCHEDULE_HUMIDITY The number of humidity sensor samples per ten seconds. This is usually set to 10.
    SCHEDULE_POWER The bit field of power-saving options. For a description of what each bit means, see Power Control Bits. Note: Enabling power-saving for a sensor will reduce the maximum sampling rate of that sensor.
    MIC_GAIN The microphone gain. 0 is the least gain, and 255 is the most gain. This is usually set to 128.
    LOG_FILE Specifies the initial log file name used when writing a log. Not used with logger.
    LOG_TYPE Sets the log type. This can either be "uwar" or "stream". Not used with logger.
    LOG_START If set to 1, enables log writing. Not used with logger.
    LOG_MAX_TIME Maximum elapsed time per log file, in seconds. Not used with logger.
    LOG_MAX_TIME Maximum log file size, in kilobytes. Not used with logger.
    EXEC_LOG_FILE Specifies the initial execution log file name when writing an execution log (the output that's sent to the console).
    EXEC_LOG_START If set to 1, writes an execution log. Not normally used, except when debugging.
    USE_IPC If set to 1, enables IPC. By itself, this configures the msb-server to listen for all IPC messages and publish the schedule and calibration. This is usually enabled.
    IPC_PUBLISH_DATA If set to 1, publishes sensor data over IPC. Not normally set.
    IPC_PUBLISH_RAW If set to 1, publishes raw sensor data over IPC. Not normally set.
    IPC_PUBLISH_STREAM If set to 1, publishes the raw serial port data stream over IPC. Not normally set.
    IPC_PUBLISH_MIC If set to 1, publishes microphone samples over IPC. Not normally set.
    SHM_PUBLISH_STREAM If set to 1, publishes the raw serial port data stream over shared memory. This should be set to 1 if using logger.
    USE_RTC If set to 1, enables reading and setting of the MSB's real-time clock. Not normally set.
    CHANGE_SYSTEM_TIME If set to 1, sets the system clock to the MSB's real-time clock. Not normally set.
    PACKET_INTERVAL_IN_MS Time interval between IPC publications. Not normally set, but defaults to 100 internally.
    GPS_ENABLE If set to 1, drives the GPS enable line high (pin 3 of P1).
    ACCEL_RANGE Sets the accelerometer range to either +/-2g or +/-6g. Valid options are 2 or 6. Defaults to 2.

example output

    Typically the msb-server will output something similar to the following. Where the final received stats will continue until the program is terminated or an error occurs.
    ./msb-server -ini ./msb.ini -ipc-publish-data
    # INFO: ********************************
    # INFO: ***********   MSB   ************
    # INFO: ********************************
    # INFO: read ini file ./msb.ini
    # INFO: initialize data structures
    # INFO: allocate data messages
    # INFO: IPC for Mobile Sensing Platform Toolkit (Ver. 1.0.0)
    # INFO: set device:
    # INFO:    port   = /dev/ttyUSB1
    # INFO:    baud   = 921600
    # INFO:    params = 8N1
    # INFO: send reset command
    # INFO: ---------------------
    # INFO: send cease command ... done
    # INFO: send rtc query command to MSB
    # INFO: current msb time = 2065-25-45 45:85:85!
    # INFO: change system time to RTC!
    # INFO: set system time failed!
    # INFO: send calibration query command to MSB
    # INFO: ---- calibration ----
    # INFO: board nr            = b
    # INFO: hardware version nr = 2
    # INFO: major soft version  = 1
    # INFO: minor soft version  = 1
    # INFO: calibration word 1  = 48224
    # INFO: calibration word 2  = 47962
    # INFO: calibration word 3  = 28705
    # INFO: calibration word 4  = 44956
    # INFO: calibration val c1  = 24112
    # INFO: calibration val c2  = 2140
    # INFO: calibration val c3  = 702
    # INFO: calibration val c4  = 448
    # INFO: calibration val c5  = 749
    # INFO: calibration val c6  = 26
    # INFO: send schedule query command to MSB
    # INFO: --- USER REQUEST  ---
    # INFO: ------ schedule -----
    # INFO: interrupt count     = 5120
    # INFO: mic hz              = 8192
    # INFO: accelerometer hz    = 512.0
    # INFO: amb light hz        = 256.0
    # INFO: barometer hz        = 7.1
    # INFO: compass hz          = 0.0
    # INFO: dals hz             = 3.0
    # INFO: humidity hz         = 1.0
    # INFO: power               = 0
    # INFO: microphone gain     = 255
    # INFO: send schedule query command to MSB
    # INFO: --- NEW SETTINGS  ---
    # INFO: ------ schedule -----
    # INFO: interrupt count     = 5120
    # INFO: mic hz              = 8192
    # INFO: accelerometer hz    = 512.0
    # INFO: amb light hz        = 256.0
    # INFO: barometer hz        = 7.1
    # INFO: compass hz          = 0.0
    # INFO: dals hz             = 3.0
    # INFO: humidity hz         = 1.0
    # INFO: power               = 0
    # INFO: microphone gain     = 255
    # INFO: ------ schedule -----
    # INFO: interrupt count     = 5120
    # INFO: mic hz              = 8192
    # INFO: accelerometer hz    = 512.0
    # INFO: amb light hz        = 256.0
    # INFO: barometer hz        = 7.1
    # INFO: compass hz          = 0.0
    # INFO: dals hz             = 3.0
    # INFO: humidity hz         = 1.0
    # INFO: power               = 0
    # INFO: microphone gain     = 255
    # INFO: -------   log   -------
    # INFO: open log-file file test-0002.uwar [test-0002.uwar]
    # INFO: write header to log file ... => 967903080
    done
    # INFO: log-max-size: 4 Mbytes
    # INFO: log-max-time: 5.00 minutes 
    # INFO: ------- start -------
    # INFO: send init command to MSB
    # INFO:  2.40 kbits/sec (0 crc of 9 packets)
    # INFO: 234.95 kbits/sec (0 crc of 169 packets)
    # INFO: 221.89 kbits/sec (0 crc of 321 packets)
    # INFO: unknown packet type 0xb4
    # INFO: 221.89 kbits/sec (0 crc of 473 packets)
    ...