DM-0373

Description

Driver can be used to command the Controller to start or stop logging and to shut down Qinsy.
With the Start logging command also the name of the recording database can be set. In addition, the driver will report an overall status which gives the status of logging and the IO status.
The driver can be used to communicate with an external controller, for instance on an AUV.
In the following description an AUV is used as the external controller.
The external part will act as a client that connects to the driver, which acts as a server.


Driver Information

Driver

Remote Control - TCP Server (Network) 

Interface Type

TCP

Driver Class Type

Terminated

UTC Driver question mark

No

Input / Output

Output

Executable

DrvRemoteControlTcpServer.exe 

Related Systems

Related Pages



Format Description

Format
Binary format


Format Description

1. General Message Structure

All messages will consist of a uniform message structure comprising a 32 bytes header and a variable size message content.
In general all strings are ASCII/UTF-8 and are all null terminated, all non- used bytes like reserved space and non-use string parts will be "zero-memoried", that is filled with binary zero's.


This header is described below:

Message Header

#

Field

Type

byte count

Description

0

QAUV

char[4]

4

Start Sequence (Always QAUV).

4

Message Size

unsigned integer

4

Size of the total message including this message header (counting from 'QUAV' to the last byte of the message).
If the content is zero the message size will be 32 bytes.

8

Message ID

unsigned short

2

ID of message ( See Message ID table)

10

Message Version*

unsigned short

2

Version number of Message (1 = initial version June 2013).

12

UTC Time Stamp 1970 (whole sec)

unsigned integer

4

UTC Time tag, whole seconds since1970.

16

UTC Time Stamp 1970 (fraction)

unsigned integer

4

UTC Time tag, seconds 1970 fraction in nanoseconds.

20

Message Counter**

unsigned integer

4

Message Counter, AUV and QINSy keep unique incrementing counters.

24

Reserved

char[8]

8

Reserved space for future fields etc. (Filled with zero's.)

After this Header the variable size content follows, see below.

*) The version number is on message-level, not for the protocol. In the future if content of a message changes the version number of only that message will be incremented. If QINSy receives a message with a newer version number the message will be ignored.
**) The Message Counter is used to identify a message uniquely, it will increment after every message that is sent. Both sides (AUV and QINSy) keep their own counters. Counter value can be used in (future) reply messages to identify which command is replied upon. It can roll over to zero, that is OK.

Message Content

After the header a variable message content follows, consisting of N Bytes, with N = Message Size (as reported by header) - 32 (size of Header).

32

Content

unsigned char[N]

N

Message Specific Content (see below)

Note that the content may have a zero length, this can be the case for simple commands without a further message content.

The message contents of the individual messages are described below:

2. Message ID's

A message can be recognized by its ID. Find below an overview of the currently defined messages. In the future more messages will be added. Note that the Command Reply is not implemented for the initial version.

ID

Message Type

Direction

Description

1

Start Logging

AUV -> QINSy

Command QINSy to start logging, optionally a name can be provided.

2

Stop Logging

AUV -> QINSy

Command QINSy to end the current logging session.

3

Overall Status

QINSy -> AUV

Reports logging status, i/o status etc.

4

Shutdown

AUV -> QINSy

Close QINSy and optionally shutdown the windows OS.

5

Remote Driver Command

QINSy -> AUV

Send a command to hardware interfaced to QINSy

1000

Command Reply

Both

(FUTURE/Not implemented for initial version) can be used to confirm (or deny) a command.

3. Messages

This chapter describes the messages in detail. Note that each message contains a header as described above.

Start Recording (ID 1)

The AUV control software can order QINSy to start logging. Naming details may optionally be provided. Direction is from AUV to QINSy. If QINSy is already recording the command will be ignored.

#

Field

Type

byte count

Description

0

Header

Header (see Table 1)

32

General Header

32

Name Mode

unsigned char

1

See Table Below

33

Descriptor

char[128] UTF-8/ASCII null terminated

128

Database name


Name Mode:

Value

Description

0

Ignore Descriptor details, start recording with the current naming convention as defined in QINSy.

1

Use provided Descriptor as part of the database name and start recording.

Stop Recording (ID 2)

The AUV control software can order Qinsy to stop logging. Direction is from AUV to QINSy. If Qinsy is not recording the command will be ignored.

#

Field

Type

byte count

Description

0

Header

Header (see Table 1)

32

General Header

Overall Status (ID 3)

Qinsy sends an overall status to the AUV computer. This is done every regular interval as defined by the user in the Database Setup program.

#

Field

Type

byte count

Description

0

Header

Header (see Table 1)

32

General Header

32

I/O  Error Status

unsigned integer

4

Flags per system Category (0 = no error, 1 = error)
See table below for bit layout.

36

Recording Flag

char

1

Not Recording (0), Recording (1)

37

Recording File Counter

unsigned integer

4

Number of Databases written since start-up of Qinsy, starts at zero on startup of Qinsy.

41

Free Disk Size

unsigned integer

4

Free disk space in Mega Bytes.

45

Current Database Name

char[256] UTF-8/ASCII null terminated

256

The name of the current logging or, if not recording, of the upcoming database name.

I/O Error Status Table

This reports whether data is being properly decoded in Qinsy for a certain system category:

Bit

Description

0

I/O status Positioning Systems

1

I/O status Gyro Compasses

2

I/O status Pitch,Roll & Heave Sensors

3

I/O status Sonars (SBE,MBE,SSS)

4

I/O status PPS/Time Sync

5

I/O status Other*

*) Other means any other observation that is not part of the specific categories.

Shutdown (ID 4)

The AUV control software can order Qinsy to shut down itself and optionally to shut down the OS. If recording is active then that will be stopped.
It can not be guaranteed that the Windows OS is actually shutting down although Qinsy will issue the correct API call.

#

Field

Type

byte count

Description

0

Header

Header (see Table 1)

32

General Header

32

unsigned char

Shutdown Mode

1

See Table Below

Shutdown Mode

Value

Description

0

Shutdown Qinsy only

1

Shutdown Qinsy & Windows OS

Command Reply (ID 1000)

Currently not implemented!!! For future reference.

#

Field

Type

byte count

Description

0

Header

Header (see Table 1)

32

General Header

32

Reply

unsigned char

1

0 = Denied, 1 = Confirmed

33

Message ID

unsigned short

2

Original message that is replied upon

35

Message Counter

unsigned integer

4

Original message counter that is replied upon

39

Error Code

unsigned integer

4

In case an error is returned this value will be NON-ZERO. In the future a table with error codes will be added.

Driver Command (ID 5)

Multiple driver commands can be sent to the Qinsy at once. Therefore, at top level, the driver command is an aggregation of multiple driver commands:

#

Field

Type

byte count

Description

0

Header

Header (see Table 1)

32

General Header

32

Driver command 1

Driver command

X


32 + X

Driver command 1

Driver command

Y


32 + X + Y + ...

Driver command N





Each individual driver command consists of a command header (which's layout is equal for all driver command types) and the command's payload

Individual driver command header

#

Field

Type

byte count

Description

0

Driver command ID

Integer

4

 The command to send to the driver as described in table

4

Size of command

Integer

4

The total size of the driver command including header. If the payload of the command is one byte, this field will have value 141

8

Subsystem ID

Integer

4

In some cases, a command should be sent to a specific subsystem of a system (for example, to distinguish between the HF and LF parts of a sidescan system when setting range).

In those cases, this field is used to select the proper subsystem for the command. In other cases, this field will be ignored. 

12

System ID Length

Integer

4

The length of the System ID string to follow

16

System ID

Char[N]

N

The ID of the system to send the command to as entered in the database setup utility. Note that this name should only contain ASCII characters

16+N

Command payload

Byte[M]

M

The payload of the command.


Driver commands
Set range

Command value

0

Description

Set the system's range in meters.

Payload type

Integer

Payload size (bytes)

4

Payload values

The range in meters

Set ping mode

Command value

1

Description

Start or stop the system pinging

Payload type

Integer

Payload size (bytes)

4

Payload values

0

Pinging off

1

Pinging on

Set system recording mode

Command value

2

Description

Set the system's external recording mode.

Some systems have a built-in mechanism to record data (for instance on an internal disk drive, or on a network drive). This command can be used to start or stop the device recording.

Payload type

Integer

Payload size (bytes)

4

Payload values

0

Recording off

1

Recording on


Set trigger mode

Command value

3

Description

Set the trigger mode of the system

Payload type

Integer

Payload size (bytes)

4

Payload values

0

Free running

1

External trigger

2

Manual trigger





Python Snippet

1. Python snippet for start and stop logging

# coding: utf-8

import binascii
import socket
import struct
import sys
import time

# Create a TCP/IP socket
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
server_address = ('localhost', 10000)
sock.connect(server_address)


#Start logging
counter = 101
seconds_epoch = int(time.time())
fraction_epoch = int((time.time())*1000 - (int(time.time())*1000))
values = (bytes("QAUV" , 'utf-8'), 161 , 1 , 1 , seconds_epoch, fraction_epoch, counter , 1 , bytes("Hello Testname" , 'utf-8'))
packer = struct.Struct('4s I H H I I I 8x ? 128s')
packed_data = packer.pack(*values)

# Send start logging
print (sys.stderr, 'sending start "%s"' % packed_data , values , len(packed_data))
sock.sendall(packed_data)


#Stop logging
counter = 102
values = (bytes("QAUV" , 'utf-8'), 32 , 2 , 1 , seconds_epoch, fraction_epoch, counter )
packer = struct.Struct('4s I H H I I I 8x')
packed_data = packer.pack(*values)

# Send stop logging
print (sys.stderr, 'sending stop "%s"' % packed_data , values , len(packed_data))
sock.sendall(packed_data)


# closing socket
print (sys.stderr, 'closing socket')
sock.close()



Database Setup

Set up a Miscellaneous system. It is not necessary to define any generic observations for correct operation.
However, for monitoring the sending and receiving of messages it is possible to add observations that indicate the number of messages sent and received.
To do this, add two observations and use the slot numbers RCVD_COUNT and SEND_COUNT.
The update rate for the driver can be set. If left at default (0) then the update rate will be once every 5 seconds.


Online

In the Controller make sure that in the Session Setup for the database File setup the 'Use formatting' is disabled. 
This Session Setup is found under the Settings menu. In the Session Setup the formatting can be found under Storage/ Database.

The IO status will be healthy until a certain age. The default age for Positioning, Heading, Sonar, Timesync and Other is 5 seconds. 
For attitude this is 1 second. The age settings are stored in the registry.