The Wayfinder DVL driver is an easy to use programming interface to communicate directly to the DVL using the serial port. The driver is written in Python and the source code can be found here. The source code also includes example applications that cover some common uses of the driver.
To get the system information from the DVL use the Dvl.get_system() function. Use Dvl.system_info property to access an instance of the SystemInfo class.
To get the system configurable settings call the Dvl.get_setup() function. Use Dvl.system_setup property to access an instance of the SystemSetup class. The SystemSetup can then be modified and sent back to Wayfinder by using the Dvl.set_setup() function.
dvl.dvl
Contains the main Dvl class used to connect to the Wayfinder DVL.
dvl.commands
Contains several classes related to sending commands to the Wayfinder DVL.
dvl.packets
Contains several classes that implement the binary packet interface.
dvl.system
Contains several classes that are used for storing information from Wayfinder DVL, including hardware and user configurable settings.
dvl.util
Contains several useful utilities classes.
DVL.DVL
Contains main Dvl class to connect to Wayfinder.
class Dvl(com=None, baudrate=115200)
Main class to connect to Wayfinder.
var system_info : SystemInfo
After successful call to get_system results are stored in here.
var system_components : SystemComponents
After successful call to get_components results are stored in here.
var system_setup : SystemSetup
After successful call to get_setup results are stored in here.
var system_tests : SystemTests
After successful call to get_tests results are stored in here.
var system_features : SystemFeatures
After successful call to get_features results are stored in here.
var fft_data : FftData
After successful call to get_fft_test results are stored in here.
var last_err
Last response from the system as dvl.commands.ResponseStatusType.
var working_folder
Path to working folder where data will be stored.
var log_file_name
Automatically generated file name when data logging starts.
var log_all_data
Flag to turn on logging of all data for debugging purposes.
var time_diff
Time different between system time and PC time.
def connect(self, com: str, baud_rate: int = 115200) -> bool
Connects to Wayfinder DVL.
com
str
baud_rate
int
bool
def disconnect(self)
Disconnects from Wayfinder DVL.
def is_connected(self) -> bool
Checks if system is connected.
def get_time(self) ->
Gets system time.
datetime
def set_time(self, date_time: ) -> bool
Sets system time.
date_time
def enter_command_mode(self) -> bool
Enters command mode (stops pinging).
def exit_command_mode(self) -> bool
Exits command mode (starts pinging).
def send_software_trigger(self) -> bool
Sends software trigger if software trigger is on.
def reset_to_defaults(self) -> bool
Resets to factory defaults.
def set_speed_of_sound(self, value: float) -> bool
Sets speed of sound value.
def get_tests(self) -> bool
Performs and gets system tests results. The results are in system_tests. It is required to send enter_command_mode() before using this command.
def start_tests(self)
Starts system tests without waiting for results.
def get_features(self) -> bool
Gets system features. The results are in system_features.
def set_system_features(self, feature_code: bytearray) -> bool
Set system features.
def get_setup(self) -> bool
Gets user setup. The results are in system_setup.
def set_setup(self, setup: SystemSetup) -> bool
Sets user setup.
def get_system(self) -> bool
Gets system information. The results are in system_info.
def get_components(self) -> bool
Gets hardware components information. The results are in system_components.
def get_fft_test(self) -> bool
Gets FFT test. The results are in fft_data.
def reset_fft(self)
Resets FFT queue.
def get_status_count(self) -> int
Gets count of status packets.
def get_status_packet(self) -> AppLayerPacket
Gets status from queue. This function should be used after starting tests and waiting for status.
AppLayerPacket
def get_test_response(self) -> bool
Gets command response for system test. Use this function after start_system_tests and checking test status.
def set_working_folder(self, working_folder: str)
Sets working folder for data logging.
working_folder
def start_logging(self, working_folder: str, prefix: str) -> bool
Starts logging data to working folder.
prefix
def get_log_file_name(self)
Returns name of log file.
def stop_logging(self)
Stops data logging.
def is_logging(self)
Checks if data are logged.
def register_ondata_callback(self, func, obj=None)
Registers on data received callback function.
The callback function should be define as follows: def func(output_data: dvl.system.OutputData, obj): where output_data are received by driver, and obj is any object.
def unregister_all_callbacks(self)
Unregisters all callback functions.
def reset(self)
Resets queues and decoder.
def change_baud_rate(self, baud_index: int) -> bool
Changes baud rate on open port.
DVL.COMMANDS
Contains several classes related to sending commands to Wayfinder.
var COMMAND_TIMEOUT_SEC
Timeout for most commands (5 sec)
var LONG_COMMAND_TIMEOUT
Timeout for commands taking longer (15 sec)
class CommandIdType(value, names=None, *, module=None, qualname=None, type=None, start=1)
Enumerated type class that defines command IDs.
var ENTER_CMD_MODE
Enter command mode (stop pinging) command ID.
var EXIT_CMD_MODE
Exit command mode (start pinging) command ID.
var SOFTWARE_TRIGGER
Software trigger command ID.
var GET_TIME
Get system time command ID.
var SET_TIME
Set system time command ID.
var GET_SYSTEM
Get system information command ID.
var SET_SYSTEM
Set system information command ID.
var GET_SETUP
Get system setup command ID.
var SET_SETUP
Set system setup command ID.
var GET_TESTS
Get test results command ID.
var GET_FEATURES
Get features command ID.
var SET_FEATURES
Set features command ID.
var GET_FFT
Get FFT test command ID.
var RESET_TO_DEFAULTS
Reset to factory defaults command ID.
var SET_SPEED_OF_SOUND
Set speed of sound command ID.
var FIRMWARE_UPDATE
Start firmware update command ID.
var UPLOAD_FILE
Upload firmware file command ID.
var GET_COMPONENTS
Get hardware components information command ID.
var SET_COMPONENTS
Set hardware components information (internal only) command ID.
class ResponseStatusType(value, names=None, *, module=None, qualname=None, type=None, start=1)
Enumerated type class that defines command response status.
var NO_RESPONSE
No response from the system.
var SUCCESS
Successful execution.
var UNKNOWN_CMD
Unknown command.
var PARAM_INVALID
One or more parameters are invalid.
var CMD_EXEC_ERR
Error in command execution.
var CMD_SET_ERR
Set command error.
var CMD_GET_ERR
Get command error.
var NORUN_WITH_PING
Cannot execute command while pinging.
var CANNOT_OPEN_PORT
Cannot open COM port.
class ResponseErrorType(value, names=None, *, module=None, qualname=None, type=None, start=1)
Enumerated type class that defines command response error.
var INVALID_NONE
No error - All parameters are valid.
var INVALID_BAUD
Invalid baud rate.
var INVALID_TRIGGER
Invalid trigger enable/disable value.
var INVALID_SOS
Invalid speed of sound.
var INVALID_MAXDEPTH
Invalid maximum depth.
var INVALID_DATETIME
Invalid date/time.
class Communicator(port=None)
Class that implements binary communication layer.
def decode_packets(self, arr)
Decodes binary packets and puts them into queues.
def send_packet(self, packet: PhysicalLayerPacket)
Sends physical layer packet to DVL.
def flush_fft_queue(self)
Flushes FFT data queue.
def flush_cmd_queue(self)
Flushes command queue.
def flush_status_queue(self)
Flushes status queue.
def get_cmd_packet(self, time_out: int = 0) -> AppLayerPacket
Gets command response packet.
def get_fft_count(self)
Returns number of available FFT packets.
def get_fft_packet(self, time_out)
Gets the FFT packet from queue.
def get_status_count(self)
Returns number of available status packets.
def get_status_packet(self, time_out)
Gets the data packet from queue.
def send_and_wait_for_response(self, packet: AppLayerPacket, timeout: int = 0, debug: bool = False) -> AppLayerPacket
Sends packet and waits for response.
def register_ondata_callback(self, func, obj)
Registers receive callback function.
class BinaryCommands(port=None)
Binary commands interface.
def enter_command_mode(self) -> ResponseStatusType
def exit_command_mode(self) -> ResponseStatusType
Exits command mode (start pinging).
def reset_to_defaults(self) -> ResponseStatusType
def get_time(self)
def set_time(self, date_time: )
def set_speed_of_sound(self, value: float)
Sets speed of sound.
def get_system(self)
Gets DVL system information.
def get_components(self)
Gets DVL hardware components information.
def get_tests(self)
Gets DVL system tests.
def get_setup(self)
Gets user setup.
def set_setup(self, setup: SystemSetup)
def get_features(self)
Gets DVL system features.
def set_system_features(self, feature_code: bytearray)
Sets DVL features.
def send_software_trigger(self)
Sends software trigger to ping
def send_cmd(self, cmd: CommandIdType, timeout=5) -> (ResponseStatusType'>, AppLayerPacket'>)
Sends command and waits for response.
Uploads chunk of the file.
Sends command without waiting for response.
INHERITED MEMBERS
Checks command response.
DVL.PACKETS
Contains several classes that implement binary packet interface.
class AppLayerIdType(value, names=None, *, module=None, qualname=None, type=None, start=1)
Enumerated type class that defines IDs for application layer packets.
var UNKNOWN
var CMD_2LETTER
Two letter command.
var RSP_2LETTER
Two letter response.
var CMD_BIN
Binary command.
var RSP_BIN
Binary response.
var DATA_PD
Binary data.
var DATA_NMEA
NMEA data.
var STATUS
Status response.
var FFT_DATA
FFT data.
class AppLayerPacket(arr=None)
Application layer communications interface.
def get_payload(self)
Returns payload of application layer packet
def get_bytes(self)
Returns byte array that corresponds to application layer packet
def create_empty(self)
Creates empty packet
def create_from_array(self, arr: bytearray) -> bytearray
Creates application layer packet from byte array
def create_from_payload(self, packet_id: int, payload: bytearray)
Creates application layer packet from payload
class PhysicalLayerPacket(payload: AppLayerPacket = None, packet_id: int = 1, version: int = 16)
Physical layer communications interface
var PACKET_VER
Packet version number.
var PACKET_ID
Packet ID number.
var MIN_PACKET_LEN
Minimum packet length.
var CHECKSUM_LENGTH
Checksum length.
var version : int
Physical layer packet version.
var packet_id : int
Physical layer packet ID.
var length : int
The length of the physical layer packet minus the checksum.
var payload : AppLayerPacket
The application layer packet encoded into a bytearray.
bytearray
var checksum : int
The checksum of the physical layer packet.
def encode(self) -> bytearray
Converts the packet into its bytearray representation.
class DecoderState(value, names=None, *, module=None, qualname=None, type=None, start=1)
Enumerated type class that defines state of the decoder.
var START_BYTE
Searching for packet start byte.
var VER_BYTE
Searching for packet version number.
var PKT_ID
Searching for packet ID.
var PKT_LEN
Searching for packet length.
var PAYLOAD
Searching for payload.
var CHECKSUM
Searching for checksum.
class PacketDecoder
Finds and decodes physical layer packets.
def parse_bytes(self, arr)
Parses bytes array.
def clear(self)
Clears decoder state.
def on_start(self, byte)
Searches for start of the packet.
def on_ver(self, byte)
Decodes version.
def on_id(self, byte)
Decodes packet ID.
def on_len(self, byte)
Decodes packet length.
def on_payload(self, byte)
Decodes payload.
def on_checksum(self, byte)
Decodes and checks checksum.
def restart(self)
Restarts search.
def parse_byte(self, byte)
Parses one byte.
def decode(packet: bytearray) -> PhysicalLayerPacket
Convert a bytearray that represents a physical layer packet into a PhysicalLayerPacket object.
packet
PhysicalLayerPacket
def calc_checksum(arr: bytearray) -> int
Calculates a 2 byte sum of the byte array ignoring rollover.
arr
DVL.SYSTEM
Contains several classes that hold information from Wayfinder.
class DateTime
Date and time helper class for getting/setting system time.
def decode(packet: AppLayerPacket)
Decodes date and time from application layer packet.
def encode(date_time: <module 'datetime' from 'c:\\users\\apulawska\\.conda\\envs\\wayfinder_tools\\lib\\datetime.py'>, cmd_id: int) -> AppLayerPacket
Encodes date and time into application layer packet.
cmd_id
class SystemInfo
Class that contains system information.
var is_valid
Defines if data in the class are valid (i.e. they are decoded properly)
var struct_id
Structure ID number.
var version
Structure version number.
var size
Structure size.
var frequency
System frequency in Hz.
var fw_major_version
Firmware major number.
var fw_minor_version
Firmware minor number.
var fw_patch_version
Firmware patch number.
var fw_build_version
Firmware build number.
var fpga_version
FPGA firmware number.
var system_id
System ID number.
var xducer_type
Transducer type.
var beam_angle
Beam angle in degrees (for Wayfinder 30 deg).
var has_vertical_beam
Defines if vertical beam is present.
var system_type
System type (for Wayfinder 76).
var system_subtype
System sub-type (for Wayfinder 0).
def to_string(self)
Outputs information to string for logging
def decode(self, packet: AppLayerPacket)
Decodes system info from application layer packet.
def decode_from_array(self, arr: bytearray)
Decodes system info from byte array.
def get_fw_version(self)
Returns firmware version string in format 'x.xx.xx.xx'.
def get_settings(self)
Returns system info in form of settings.
class SystemComponents
Class that contains system hardware components information.
var num_hardware
Number of hardware boards.
var hardware_pn
List of part numbers for hardware.
var hardware_rev
List of revision numbers for hardware.
var hardware_sn
List of serial numbers for hardware.
def get_index(self, string)
Returns index of string in part number.
class SystemFeatures
Class that contains system features results.
def encode(feature_code: bytearray, cmd_id: int)
Encodes arr of feature codes to AppLayerPacket.
var features
List of features status: (1 installed, 0 not).
Decodes system features from byte array.
Decodes system features from application layer packet.
Returns array of settings for features.
class SystemSetup
Class that contains user system setup.
def encode(setup, cmd_id: int)
Encodes system setup to application layer packet.
var software_trigger
Software trigger flag (0 - disabled, 1 - enabled).
var baud_rate_type
Baud rate type (3 - 9600, 7 - 115200).
var speed_of_sound
Speed of sound in m/s.
var max_depth
Maximum tracking depth in meters.
var max_vb_range
Maximum vertical beam range in meters.
Decodes system setup from byte array.
Decodes system setup from application layer packet.
Returns system setup in form of settings.
def set_from_settings(self, settings)
Sets system setup from settings.
class SystemTests
Class that contains system tests results.
var tests
List of test results.
def decode(self, pkt: AppLayerPacket)
Decodes system tests from application layer packet.
Decodes system tests from byte array.
Returns arrays of settings for tests.
class SystemUpdate
Class that contains system firmware update logic.
def encode(file_size: int, chunk_size: int, cmd_id: int)
Encodes request to start firmware update to AppLayerPacket.
def encode_data(data: bytearray, cmd_id: int, chunk_size: int)
class SystemUpdateStatus
Class that contains system firmware update status.
Structure size
var monolith
Monolith status.
var fpga_image
FPGA image status.
var fpga_update
FPGA update status.
var apps_image
Firmware image status.
var apps_update
Firmware update status.
Decodes system firmware update status from byte array.
Decodes system update from application layer packet.
class OutputData(arr: bytearray)
Class that contains output ping data.
var COORDINATES
List of coordinate systems ("Beam", "XYZ", "Ship", "Earth").
Defines if data in the class are valid.
var count
Count used externally to count number of data packets.
System type (76 for Wayfinder).
System sub-type (0 for Wayfinder).
var year
Part of ping time stamp - year.
var month
Part of ping time stamp - month.
var day
Part of ping time stamp - day.
var hour
Part of ping time stamp - hour.
var minute
Part of ping time stamp - minute.
var second
Part of ping time stamp - second.
var coordinate_system
Coordinate system (0 - 3).
var vel_x
Beam 1 or X velocity in m/s.
var vel_y
Beam 2 or Y velocity in m/s.
var vel_z
Beam 3 or Z velocity in m/s.
var vel_err
Beam 4 or error velocity in m/s.
var range_beam1
Beam 1 range to bottom in meters.
var range_beam2
Beam 2 range to bottom in meters.
var range_beam3
Beam 3 range to bottom in meters.
var range_beam4
Beam 4 range to bottom in meters.
var mean_range
Mean range to bottom in meters.
Speed of sound used in m/s.
var status
Status word.
var bit_count
Number built in test errors.
var bit_code
Built in test error code. For more information please refer to Wayfinder DVL guide.
var voltage
Input voltage in Volts.
var transmit_voltage
Transmit voltage in Volts.
var current
Current in Amps.
var serial_number
Serial number of the system.
def is_range_valid(self, beam=None)
Returns if range to bottom is valid
beam
def is_velocity_valid(self, component=None)
Returns if velocity is valid
component
def get_fw_version(self) -> str
Gets firmware version as string
def get_date_time(self)
Gets date time
Returns data in form of settings
class FftTest
Class that contains FFT (interference) test
Encodes system setup to byte array
Structure version.
var samples_to_collect
Samples to collect.
var fft_len
FFT length.
var sample_offset
Sample offset.
var gain
Gain.
var beam_mask
Beam mask.
var bandwidth
Bandwidth.
var system_freq
System frequency.
class FftData(arr: bytearray)
Class that contains FFT (interference) test data
var NUM_BEAMS
Decodes system tests from byte array
def decode(self, packet: AppLayerPacket)
Decodes system tests from application layer packet
def process(self)
Processes FFT data
def average(self, fft)
Averages FFT
class FftBeamData(beam_no: int, fft_len: int)
Class that stores FFT beam data
var beam
Beam number (0-3)
var signal
Original signal.
var spectrum
Power spectrum.
var power_ratio
Power ratio in dB.
var peak_index
Peak index.
var frequency_peak
Frequency peak in kHz.
var power_peak
Power peak in dB.
var processed
Flag to indicate if data were processed.
def do_fft(self)
Performs FFT.
def average(self, beam_data, count: int)
Averages FFT data in a beam.
class SystemInfoIdType(value, names=None, *, module=None, qualname=None, type=None, start=1)
Enumerated type class that defines system info IDs. Used with list of settings for display.
var FREQUENCY
Frequency ID.
var FIRMWARE_VERSION
Firmware version.
var FPGA_VERSION
FPGA version.
var SYSTEM_ID
System ID.
class ComponentsIdType(value, names=None, *, module=None, qualname=None, type=None, start=1)
Enumerated type class that defines hardware components IDs. Used with list of settings for display.
var CPU_PN
CPU part number.
var XDR_PN
XDR part number.
var DSC_PN
DSC part number.
var SYS_PN
SYS part number.
var CPU_REV
CPU revision number.
var XDR_REV
XDR revision number.
var DSC_REV
DSC revision number.
var SYS_REV
SYS revision number.
var CPU_SN
CPU serial number.
var XDR_SN
XDR serial number.
var DSC_SN
DSC serial number.
var SYS_SN
SYS serial number.
var CPU_PN_SN
CPU part and serial number.
var XDR_PN_SN
XDR part and serial number.
var DSC_PN_SN
DSC part and serial number.
var SYS_PN_SN
SYS part and serial number.
class FeaturesIdType(value, names=None, *, module=None, qualname=None, type=None, start=1)
Enumerated type class that defines features IDs. Used with list of settings for display.
var BASE_ACC_FEATURE
Base accuracy feature.
var HIGH_ACC_FEATURE
High accuracy feature.
class BaudRateType(value, names=None, *, module=None, qualname=None, type=None, start=1)
Enumerated type class that defines baud rate types.
var BAUD_9600
9600 baud rate.
var BAUD_115200
115200 baud rate.
class SetupIdType(value, names=None, *, module=None, qualname=None, type=None, start=1)
Enumerated type class that defines system setup IDs. Used with list of settings for display.
Software trigger.
var BAUD_RATE_TYPE
Baud rate type
var SPEED_OF_SOUND
Speed of sound.
var MAX_RANGE
Maximum depth range.
var NUM_SETTINGS
Number of setup settings
class TestsIdType(value, names=None, *, module=None, qualname=None, type=None, start=1)
Enumerated type class that defines system tests IDs. Used with list of settings for display.
var SDRAM_TEST
SDRAM test.
var FRAM_TEST
FRAM test.
var RTC_TEST
Real-time clock test.
var EEPROM_TEST
EEPROM test.
var QSPI_DSC_TEST
QSPI/DSC test.
var ADC_TEST
ADC test.
class TestResultIdType(value, names=None, *, module=None, qualname=None, type=None, start=1)
Enumerated type class that defines system tests results IDs.
var NOT_RUN
Test was not executed yet.
var FAILED
Test failed.
var PASSED
Test passed.
var RUNNING
Test is running.
class DataIdType(value, names=None, *, module=None, qualname=None, type=None, start=1)
Enumerated type class that defines IDs for output data. Used with list of settings for display.
var COUNT
Count of packets.
var DATE
Date of the ping.
var TIME
Time of the ping.
var COORD_SYSTEM
Coordinate system.
var VEL_X
X velocity.
var VEL_Y
Y velocity.
var VEL_Z
Z velocity.
var VEL_ERR
Error velocity.
var RANGE1
Range to bottom beam 1.
var RANGE2
Range to bottom beam 2.
var RANGE3
Range to bottom beam 3.
var RANGE4
Range to bottom beam 4.
var MEAN_RANGE
Mean range to bottom.
var VOLTAGE
Input voltage.
var TRANSMIT_VOLTAGE
Transmit voltage.
var CURRENT
Transmit current.
Ping status.
var BIT_COUNT
Number of built in tests.
var BIT_CODE
Built in test code.
DVL.UTIL
Contains several utilities classes.
class Setting(setting_id, name, value, fmt='', units='')
Helper class for data display.
var INVALID
String for display when data are invalid.
var NO_DATA
String for display when there is no new data.
var setting_id
Setting's ID.
var name
Name of the setting.
var format
Format string to convert value for display.
var units
Units for the setting.
var min_value
Minimum value used for validation.
var max_value
Maximum value used for validation.
var value
Value of the setting (float, int, str).
var value_string
Display string representing value.
def set_min_max(self, min_value, max_value)
Sets minimum and maximum values.
def update(self, value)
Updates value and value_string.
class SerialPort(com='COM1', baud_rate=115200)
Class responsible for serial communications.
var com
String that represents COM port.
var baudrate
Serial port baud rate.
var serial_port
Serial port object.
def open(self, com: str, baud_rate: int) -> bool
Opens serial port.
def is_open(self) -> bool
Checks if port is open.
def close(self)
Closes serial port.
def write(self, array: bytearray)
Writes byte array to port.
array
byte array
def register_receive_callback(self, function)
function
def set_baudrate(self, baud_rate: int) -> bool
Changes baud-rate of the open port.
class DataLogger
Class responsible for data logging.
def is_logging(self) -> bool
def open_file(self, working_folder: str, prefix: str, ext='.pd') -> str
Creates file for data logging - name is auto generated (includes time stamp).
ext
def open_file_with_name(self, name: str, append=True) -> str
Creates file for logging with user specified name.
name
def close_file(self)
Closes log file.
Writes byte array to log data file.
def write_text(self, text: str)
Writes text to log data file.
text
def print_bytes(array: bytearray) -> str
Outputs byte array and formats for pretty print.
16 bytes are printed per line with additional space between 8 byte groups so that they are easier to distinguish. Example: AA 10 01 1B 00 02 03 14 00 02 00 00 1F 23 10 0C 00 00 00 14 03 1B 09 14 2E CC 01
def print_bytearray(array: bytearray) -> str
Outputs string of all bytes in HEX without any formatting.
def indent_string(string: str) -> str
Indents string for printing.
string