Modbus - GPS Bricklet

This is the description of the Modbus protocol for the GPS Bricklet. General information and technical specifications for the GPS Bricklet are summarized in its hardware description.

API

A general description of the Modbus protocol structure can be found here.

Basic Functions

BrickletGPS.get_coordinates
Function ID:
  • 1
Request:
  • empty payload
Response:
  • latitude – Type: uint32, Unit: 1/1000000 °, Range: [0 to 90000000]
  • ns – Type: char, Range: ['N', 'S']
  • longitude – Type: uint32, Unit: 1/1000000 °, Range: [0 to 180000000]
  • ew – Type: char, Range: ['E', 'W']
  • pdop – Type: uint16, Unit: 1/100, Range: [0 to 216 - 1]
  • hdop – Type: uint16, Unit: 1/100, Range: [0 to 216 - 1]
  • vdop – Type: uint16, Unit: 1/100, Range: [0 to 216 - 1]
  • epe – Type: uint16, Unit: 1 cm, Range: [0 to 216 - 1]

Returns the GPS coordinates. Latitude and longitude are given in the DD.dddddd° format, the value 57123468 means 57.123468°. The parameter ns and ew are the cardinal directions for latitude and longitude. Possible values for ns and ew are 'N', 'S', 'E' and 'W' (north, south, east and west).

PDOP, HDOP and VDOP are the dilution of precision (DOP) values. They specify the additional multiplicative effect of GPS satellite geometry on GPS precision. See here for more information.

EPE is the "Estimated Position Error". This is not the absolute maximum error, it is the error with a specific confidence. See here for more information.

This data is only valid if there is currently a fix as indicated by get_status.

BrickletGPS.get_status
Function ID:
  • 2
Request:
  • empty payload
Response:
  • fix – Type: uint8, Range: See meanings
  • satellites_view – Type: uint8, Range: [0 to 255]
  • satellites_used – Type: uint8, Range: [0 to 255]

Returns the current fix status, the number of satellites that are in view and the number of satellites that are currently used.

Possible fix status values can be:

Value Description
1 No Fix, get_coordinates, get_altitude and get_motion return invalid data
2 2D Fix, only get_coordinates and get_motion return valid data
3 3D Fix, get_coordinates, get_altitude and get_motion return valid data

There is also a blue LED on the Bricklet that indicates the fix status.

The following meanings are defined for the elements of this function:

For fix:

  • 1 = No Fix
  • 2 = 2D Fix
  • 3 = 3D Fix
BrickletGPS.get_altitude
Function ID:
  • 3
Request:
  • empty payload
Response:
  • altitude – Type: int32, Unit: 1 cm, Range: [-231 to 231 - 1]
  • geoidal_separation – Type: int32, Unit: 1 cm, Range: [-231 to 231 - 1]

Returns the current altitude and corresponding geoidal separation.

This data is only valid if there is currently a fix as indicated by get_status.

BrickletGPS.get_motion
Function ID:
  • 4
Request:
  • empty payload
Response:
  • course – Type: uint32, Unit: 1/100 °, Range: [0 to 36000]
  • speed – Type: uint32, Unit: 1/100 km/h, Range: [0 to 232 - 1]

Returns the current course and speed. A course of 0° means the Bricklet is traveling north bound and 90° means it is traveling east bound.

Please note that this only returns useful values if an actual movement is present.

This data is only valid if there is currently a fix as indicated by get_status.

BrickletGPS.get_date_time
Function ID:
  • 5
Request:
  • empty payload
Response:
  • date – Type: uint32, Range: [10100 to 311299]
  • time – Type: uint32, Range: [0 to 235959999]

Returns the current date and time. The date is given in the format ddmmyy and the time is given in the format hhmmss.sss. For example, 140713 means 14.07.13 as date and 195923568 means 19:59:23.568 as time.

Advanced Functions

BrickletGPS.restart
Function ID:
  • 6
Request:
  • restart_type – Type: uint8, Range: See meanings
Response:
  • no response

Restarts the GPS Bricklet, the following restart types are available:

Value Description
0 Hot start (use all available data in the NV store)
1 Warm start (don't use ephemeris at restart)
2 Cold start (don't use time, position, almanacs and ephemeris at restart)
3 Factory reset (clear all system/user configurations at restart)

The following meanings are defined for the elements of this function:

For restart_type:

  • 0 = Hot Start
  • 1 = Warm Start
  • 2 = Cold Start
  • 3 = Factory Reset
BrickletGPS.get_identity
Function ID:
  • 255
Request:
  • empty payload
Response:
  • uid – Type: char[8]
  • connected_uid – Type: char[8]
  • position – Type: char, Range: ['a' to 'h', 'z']
  • hardware_version – Type: uint8[3]
    • 0: major – Type: uint8, Range: [0 to 255]
    • 1: minor – Type: uint8, Range: [0 to 255]
    • 2: revision – Type: uint8, Range: [0 to 255]
  • firmware_version – Type: uint8[3]
    • 0: major – Type: uint8, Range: [0 to 255]
    • 1: minor – Type: uint8, Range: [0 to 255]
    • 2: revision – Type: uint8, Range: [0 to 255]
  • device_identifier – Type: uint16, Range: [0 to 216 - 1]

Returns the UID, the UID where the Bricklet is connected to, the position, the hardware and firmware version as well as the device identifier.

The position can be 'a', 'b', 'c', 'd', 'e', 'f', 'g' or 'h' (Bricklet Port). A Bricklet connected to an Isolator Bricklet is always at position 'z'.

The device identifier numbers can be found here

Callback Configuration Functions

BrickletGPS.set_coordinates_callback_period
Function ID:
  • 7
Request:
  • period – Type: uint32, Unit: 1 ms, Range: [0 to 232 - 1], Default: 0
Response:
  • no response

Sets the period with which the CALLBACK_COORDINATES callback is triggered periodically. A value of 0 turns the callback off.

The CALLBACK_COORDINATES callback is only triggered if the coordinates changed since the last triggering.

BrickletGPS.get_coordinates_callback_period
Function ID:
  • 8
Request:
  • empty payload
Response:
  • period – Type: uint32, Unit: 1 ms, Range: [0 to 232 - 1], Default: 0

Returns the period as set by set_coordinates_callback_period.

BrickletGPS.set_status_callback_period
Function ID:
  • 9
Request:
  • period – Type: uint32, Unit: 1 ms, Range: [0 to 232 - 1], Default: 0
Response:
  • no response

Sets the period with which the CALLBACK_STATUS callback is triggered periodically. A value of 0 turns the callback off.

The CALLBACK_STATUS callback is only triggered if the status changed since the last triggering.

BrickletGPS.get_status_callback_period
Function ID:
  • 10
Request:
  • empty payload
Response:
  • period – Type: uint32, Unit: 1 ms, Range: [0 to 232 - 1], Default: 0

Returns the period as set by set_status_callback_period.

BrickletGPS.set_altitude_callback_period
Function ID:
  • 11
Request:
  • period – Type: uint32, Unit: 1 ms, Range: [0 to 232 - 1], Default: 0
Response:
  • no response

Sets the period with which the CALLBACK_ALTITUDE callback is triggered periodically. A value of 0 turns the callback off.

The CALLBACK_ALTITUDE callback is only triggered if the altitude changed since the last triggering.

BrickletGPS.get_altitude_callback_period
Function ID:
  • 12
Request:
  • empty payload
Response:
  • period – Type: uint32, Unit: 1 ms, Range: [0 to 232 - 1], Default: 0

Returns the period as set by set_altitude_callback_period.

BrickletGPS.set_motion_callback_period
Function ID:
  • 13
Request:
  • period – Type: uint32, Unit: 1 ms, Range: [0 to 232 - 1], Default: 0
Response:
  • no response

Sets the period with which the CALLBACK_MOTION callback is triggered periodically. A value of 0 turns the callback off.

The CALLBACK_MOTION callback is only triggered if the motion changed since the last triggering.

BrickletGPS.get_motion_callback_period
Function ID:
  • 14
Request:
  • empty payload
Response:
  • period – Type: uint32, Unit: 1 ms, Range: [0 to 232 - 1], Default: 0

Returns the period as set by set_motion_callback_period.

BrickletGPS.set_date_time_callback_period
Function ID:
  • 15
Request:
  • period – Type: uint32, Unit: 1 ms, Range: [0 to 232 - 1], Default: 0
Response:
  • no response

Sets the period with which the CALLBACK_DATE_TIME callback is triggered periodically. A value of 0 turns the callback off.

The CALLBACK_DATE_TIME callback is only triggered if the date or time changed since the last triggering.

BrickletGPS.get_date_time_callback_period
Function ID:
  • 16
Request:
  • empty payload
Response:
  • period – Type: uint32, Unit: 1 ms, Range: [0 to 232 - 1], Default: 0

Returns the period as set by set_date_time_callback_period.

Callbacks

BrickletGPS.CALLBACK_COORDINATES
Function ID:
  • 17
Response:
  • latitude – Type: uint32, Unit: 1/1000000 °, Range: [0 to 90000000]
  • ns – Type: char, Range: ['N', 'S']
  • longitude – Type: uint32, Unit: 1/1000000 °, Range: [0 to 180000000]
  • ew – Type: char, Range: ['E', 'W']
  • pdop – Type: uint16, Unit: 1/100, Range: [0 to 216 - 1]
  • hdop – Type: uint16, Unit: 1/100, Range: [0 to 216 - 1]
  • vdop – Type: uint16, Unit: 1/100, Range: [0 to 216 - 1]
  • epe – Type: uint16, Unit: 1 cm, Range: [0 to 216 - 1]

This callback is triggered periodically with the period that is set by set_coordinates_callback_period. The parameters are the same as for get_coordinates.

The CALLBACK_COORDINATES callback is only triggered if the coordinates changed since the last triggering and if there is currently a fix as indicated by get_status.

BrickletGPS.CALLBACK_STATUS
Function ID:
  • 18
Response:
  • fix – Type: uint8, Range: See meanings
  • satellites_view – Type: uint8, Range: [0 to 255]
  • satellites_used – Type: uint8, Range: [0 to 255]

This callback is triggered periodically with the period that is set by set_status_callback_period. The parameters are the same as for get_status.

The CALLBACK_STATUS callback is only triggered if the status changed since the last triggering.

The following meanings are defined for the elements of this function:

For fix:

  • 1 = No Fix
  • 2 = 2D Fix
  • 3 = 3D Fix
BrickletGPS.CALLBACK_ALTITUDE
Function ID:
  • 19
Response:
  • altitude – Type: int32, Unit: 1 cm, Range: [-231 to 231 - 1]
  • geoidal_separation – Type: int32, Unit: 1 cm, Range: [-231 to 231 - 1]

This callback is triggered periodically with the period that is set by set_altitude_callback_period. The parameters are the same as for get_altitude.

The CALLBACK_ALTITUDE callback is only triggered if the altitude changed since the last triggering and if there is currently a fix as indicated by get_status.

BrickletGPS.CALLBACK_MOTION
Function ID:
  • 20
Response:
  • course – Type: uint32, Unit: 1/100 °, Range: [0 to 36000]
  • speed – Type: uint32, Unit: 1/100 km/h, Range: [0 to 232 - 1]

This callback is triggered periodically with the period that is set by set_motion_callback_period. The parameters are the same as for get_motion.

The CALLBACK_MOTION callback is only triggered if the motion changed since the last triggering and if there is currently a fix as indicated by get_status.

BrickletGPS.CALLBACK_DATE_TIME
Function ID:
  • 21
Response:
  • date – Type: uint32, Range: [10100 to 311299]
  • time – Type: uint32, Range: [0 to 235959999]

This callback is triggered periodically with the period that is set by set_date_time_callback_period. The parameters are the same as for get_date_time.

The CALLBACK_DATE_TIME callback is only triggered if the date or time changed since the last triggering.