<title>Usage of IMU/GPS logger ($script_name)</title>
</head>
<body>
<h2>Usage of IMU/GPS logger ($script_name)</h2>
<p>This script controls IMU/GPS logger. When the camera starts, the script looks for the <i>/etc/imu_logger.xml</i>" and if it is found, the settings from this file are applied to the logger. If there is no such file (i.e. at first boot after reflashing the camera) script looks for the optional extension boards <a href=""http://wiki.elphel.com/index.php?title=103695>103695</a> and <a href="http://wiki.elphel.com/index.php?title=103696">103696</a> and uses the information from their flash memory (not erased during reflash) combined with the defaults to create initial <i>/etc/imu_logger.xml</i> file that can be modified later</p>
<p>Script receives parameters as HTTP GET request, there are five special parameters:
<ul>
<li><b><a href="$prefix_url?source">source</a></b> - returns the source of this script</li>
<li><b><a href="$prefix_url?list">list</a></b> - returns an XML containing current logger settings, the names of the nodes can be used to modify specific settings</li>
<li><b>save</b> - overwrite <i>/etc/imu_logger.xml</i> with the current settings - they will be used next time camera will boot up</li>
<li><b>msg=url-encoded-text-up-to-56-bytes</b> - set the "odometer" message that will be logged next time the external input is toggled </li>
<li><b>smsg=url-encoded-text-up-to-56-bytes</b> - (not yet implemented) set the "odometer" message and trigger logging immediately</li>
</ul>
Other parameters are just <i>name=value</i> pairs with colons separating names and subnames
<ul>
<li><b>imu_period</b> - set the IMU logging period in SPI SCLK periods, maybe set to <i>auto</i> (default value, same as 0xff000000) to log when the IMU data is ready. Value 0 turns the IMU logging off</li>
<li><b>sclk_freq</b> - set SPI clock frequency, in Hz. Default is 5000000 (5MHz)</li>
<li><b>stall</b> - set SPI 'stall' time, in microseconds. Default is 2 usec</li>
<li><b>baud_rate</b> - set baud rate for the serial GPS, default is 19200</li>
<li><b>imu_slot</b> - specify the IMU board (<a href="http://wiki.elphel.com/index.php?title=103695">103695</a>) connection to the <a href="http://wiki.elphel.com/index.php?title=10369">10369</a> board 0 - none, 1 - J9, 2 - J10, 3 - J11. Default is 1 (J9)</li>
<li><b>gps_slot</b> - specify the GPS board (<a href="http://wiki.elphel.com/index.php?title=103696">103696</a>) connection to the <a href="http://wiki.elphel.com/index.php?title=10369">10369</a> board 0 - none, 1 - J9, 2 - J10, 3 - J11. Default is 2 (J10)</li>
<li><b>gps_mode</b> - synchronization mode for the GPS: 0 - pulse-per-sample external input, negative front, 1 - pps input positive front, 2 - start of a first sentence after pause, 3 - start of each individual sentence. Mode 2 is the default, modes 0 and 1 require that GPS has a dedicated synchro output</li>
<li><b>msg_conf</b> - GPIO number and polarity (+16 - invert polarity) uses to log external events (i.e. odometer pulses from a vehicle wheel sensor). Timestamp uses leading edge, software may write to the 56-byte buffer (see 'msg=' command above) before the trailing edge to attach the message to the event after the event occured. In the case of short external pulses the logged message will be the last written before the event</li>
<li><b>img_sync</b> - 0 - disable logging of the images, 1 - enable. In the case of the multiple synchronized cameras this provides a way to match external (master) camera timestamps transmitted over the synchronization cable, with the local camera timestamps used by the logger - both are logged. Default is 1</li>
<li><b>extra_conf</b> - Development signals (0 - config_long_sda_en, 1 -config_late_clk, 2 - config_single_wire, should be set for 103695 rev A). Default is 4</li>
<li><b>slow_spi</b> - may be set to 1 for slow SPI devices (other changes may be needed, i.e. changing power from 3.3V to 5.0V selected by a resistor divider). Default is 0 </li>
<li><b>sleep_busy</b> - setting for the driver. It is a sleep time (in microseconds) before the driver will poll the logger buffer if it does not have the full sample record (64 bytes of data) ready</li>
<li><b>imu_registers</b> - setting the IMU register addresses to be logged (total number of logged registers is 28). You may see the complete list of the registers in the IMU datasheet. The registers are addressed as 'imu_registers:NN', where NN is the register sequnce number, starting with 0. Below are the default values:
<ul>
<li><b>imu_registers:0</b>=0x10 - x gyro low</li>
<li><b>imu_registers:1</b>=0x12 - x gyro high</li>
<li><b>imu_registers:2</b>=0x14 - y gyro low</li>
<li><b>imu_registers:3</b>=0x16 - y gyro high</li>
<li><b>imu_registers:4</b>=0x18 - z gyro low</li>
<li><b>imu_registers:5</b>=0x1a - z gyro high</li>
<li><b>imu_registers:6</b>=0x1c - x accel low</li>
<li><b>imu_registers:7</b>=0x1e - x accel high</li>
<li><b>imu_registers:8</b>=0x20 - y accel low</li>
<li><b>imu_registers:9</b>=0x22 - y accel high</li>
<li><b>imu_registers:10</b>=0x24 - z accel low</li>
<li><b>imu_registers:11</b>=0x26 - z accel high</li>
<li><b>imu_registers:12</b>=0x40 - x delta angle low</li>
<li><b>imu_registers:13</b>=0x42 - x delta angle high</li>
<li><b>imu_registers:14</b>=0x44 - y delta angle low</li>
<li><b>imu_registers:15</b>=0x46 - y delta angle high</li>
<li><b>imu_registers:16</b>=0x48 - z delta angle low</li>
<li><b>imu_registers:17</b>=0x4a - z delta angle high</li>
<li><b>imu_registers:18</b>=0x4c - x delta velocity low</li>
<li><b>imu_registers:19</b>=0x4e - x delta velocity high</li>
<li><b>imu_registers:20</b>=0x50 - y delta velocity low</li>
<li><b>imu_registers:21</b>=0x52 - y delta velocity high</li>
<li><b>imu_registers:22</b>=0x54 - z delta velocity low</li>
<li><b>imu_registers:23</b>=0x56 - z delta velocity high</li>
<li><b>nmea</b> - set format of the four logged NMEA sentences. For each sentence two text fields have to be specified - 'sentence' (the three letters following the comman prefix '$GP'), and 'format' that consists of a sequence of 'n' (for number) and 'b' (for bytes), up to 24 total. Numbers consisting of digits, minus sign and decimal point are encoded with 2 digits per byte (to make sure the longest sentence fits into the 56 byte logger payload buffer), followed by the 0xf nibble (half-byte). Bytes are encoded with MSB cleared ( & 0x7f) for all bytes in a field but the last, the last byte has it set (|0x80). Empty byte field is logged as 0xff. Below are the default settings:
'imu_period'=>'auto',// 0xFFFFFFFF, // 0 - off, >=0xff000000 - "when ready", else - number of SCLK periods
'sclk_freq'=>5000000,// $clkr_divr= 8, // 80MHz divisor to get half SCLK rate (defaulkt SCLK=5MHz)
'stall'=>2,// SPI stall time in usec
'baud_rate'=>19200,// $rs232_div=80/2/$baud
'imu_slot'=>1,
'gps_slot'=>2,
'gps_mode'=>2,// 0 - pps neg, 1 - pps pos, 2 - start of first sentence after pause, 3 start of sentence
'msg_conf'=>10,// GPIO bit number for external (odometer) input (+16 - invert polarity). Timestamp uses leading edge, software may write to 56-byte buffer before the trailing edge
'extra_conf'=>4,// 0 - config_long_sda_en, 1 -config_late_clk, 2 - config_single_wire, should be set for 103695 rev "A"
'slow_spi'=>0,// set to 1 for slow SPI devices (0 for ADIS-16375)
'imu_sa'=>3,// i2c slave address modifier for the 103695A pca9500
'sleep_busy'=>30000,//microseconds
'imu_registers'=>array(/// Up to 28 total
0x10,// x gyro low
0x12,// x gyro high
0x14,// y gyro low
0x16,// y gyro high
0x18,// z gyro low
0x1a,// z gyro high
0x1c,// x accel low
0x1e,// x accel high
0x20,// y accel low
0x22,// y accel high
0x24,// z accel low
0x26,// z accel high
0x40,// x delta angle low
0x42,// x delta angle high
0x44,// y delta angle low
0x46,// y delta angle high
0x48,// z delta angle low
0x4a,// z delta angle high
0x4c,// x delta velocity low
0x4e,// x delta velocity high
0x50,// y delta velocity low
0x52,// y delta velocity high
0x54,// z delta velocity low
0x56,// z delta velocity high
0x0e,// temperature
0x70,// time m/s
0x72,// time d/h
0x74// time y/m
),
'nmea'=>array(
/// first three letters - sentence to log (letters after "$GP"). next "n"/"b" (up to 24 total) - "n" number (will be encoded 2 digits/byte, follwed by "0xF"
/// "b" - byte - all but last will have MSB 0 (& 0x7f), the last one - with MSB set (| 0x80). If there are no characters in the field 0xff will be output
array('RMC','nbnbnbnnnnb'),
array('GGA','nnbnbnnnnbnbbb'),
array('GSA','bnnnnnnnnnnnnnnnn'),
array('VTG','nbnbnbnb')
),
'message'=>'Odometer message'// Message - up to 56 bytes
);
return$default_config;
}
/**
Combines $conf and $dflt arrays - all driver parameters are overwritten aftre the call
'imu_period'=>'auto',// 0xFFFFFFFF, // 0 - off, >=0xff000000 - "when ready", else - number of SCLK periods
'sclk_freq'=>5000000,// $clkr_divr= 8, // 80MHz divisor to get half SCLK rate (defaulkt SCLK=5MHz)
'stall'=>2,// SPI stall time in usec
'baud_rate'=>19200,// $rs232_div=80/2/$baud
'imu_slot'=>1,
'gps_slot'=>2,
'gps_mode'=>2,// 0 - pps pos, 1 - pps neg, 2 - start of first sesntence after pause, 3 start of sentence
'msg_conf'=>10,// GPIO bit number for external (odometer) input (+16 - invert polarity). Timestamp uses leading edge, software may write to 56-byte buffer before the trailing edge
'extra_conf'=>4,// 0 - config_long_sda_en, 1 -config_late_clk, 2 - config_single_wire, should be set for 103695 rev "A"
'slow_spi'=>0,// set to 1 for slow SPI devices (0 for ADIS-16375)
'imu_sa'=>3,// i2c slave address modifier for the 103695A pca9500
'sleep_busy'=>30000,//microseconds
'imu_registers'=>array(/// Up to 28 total
0x10,// x gyro low
0x12,// x gyro high
0x14,// y gyro low
0x16,// y gyro high
0x18,// z gyro low
0x1a,// z gyro high
0x1c,// x accel low
0x1e,// x accel high
0x20,// y accel low
0x22,// y accel high
0x24,// z accel low
0x26,// z accel high
0x40,// x delta angle low
0x42,// x delta angle high
0x44,// y delta angle low
0x46,// y delta angle high
0x48,// z delta angle low
0x4a,// z delta angle high
0x4c,// x delta velocity low
0x4e,// x delta velocity high
0x50,// y delta velocity low
0x52,// y delta velocity high
0x54,// z delta velocity low
0x56,// z delta velocity high
0x0e,// temperature
0x70,// time m/s
0x72,// time d/h
0x74// time y/m
),
'nmea'=>array(
/// first three letters - sentence to log (letters after "$GP"). next "n"/"b" (up to 24 total) - "n" number (will be encoded 4 digits/byte, follwed by "0xF"
/// "b" - byte - all but last will have MSB 0 (& 0x7f), the last one - with MSB set (| 0x80). If there are no characters in the field 0xff will be output
array('RMC','nbnbnbnnnnb'),
array('GGA','nnbnbnnnnbnbbb'),
array('GSA','bnnnnnnnnnnnnnnnn'),
array('VTG','nbnbnbnb')
),
'message'=>'Odometer message'// Message - up to 56 bytes
);
return$default_config;
}
/**
Combines $conf and $dflt arrays - all driver parameters are overwritten aftre the call