OSTC Companion  3.0
Companion sofftware for H&W dive computers
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Member Functions | Protected Types | Protected Member Functions | Protected Attributes | List of all members
OSTC3Operations Class Reference

Implementing various low-level operations for OSTC3 dive computer. More...

#include <OSTC3Operations.h>

Inheritance diagram for OSTC3Operations:
Inheritance graph
[legend]

Public Member Functions

 OSTC3Operations ()
 
 ~OSTC3Operations ()
 
int firmware () const override
 The fw version found during the last getIdentty(). More...
 
int serialNumber () const override
 The serial number found during the last getIdentty(). More...
 
QString customText () const override
 The user-defined string found during the last getIdentty(). More...
 
QSize nameSize () const override
 Custom text size (lines and columns). More...
 
void getIdentity () override
 Read OSTC3 computer firmware, serial and custom text. Everything is formated for the description() string. More...
 
void writeText (const QString &msg) override
 Display a short text on OSTC3 while on service mode. OSTC3 can handle 16 chars. So the string is automatically padded with spaces to clean any leftover. More...
 
QString firmwareTemplate () const override
 filename matching template for compatible firmware. More...
 
bool connect () override
 
bool disconnect (bool closing=false) override
 Close connection. More...
 
void setDate (const QDateTime &date) override
 Set HW dive computer date and time. More...
 
void setName (const QString &newName) override
 Set HW dive computer user text. More...
 
void setIcons (const QString &fileName) override
 Set HW dive computer icon set. More...
 
QImage dumpScreen () const override
 Take a snapshot of the connected computer's screen. More...
 
void upgradeFW (const QString &fileName) override
 Upgrade HW dive computer firmware. More...
 
void loadFirmware (HexFile &hex, const QString &fileName) const override
 Read in the specific firmware file format. More...
 
- Public Member Functions inherited from HardwareOperations
virtual ~HardwareOperations ()
 mandatory (and empty) virtual descructor in the base class. More...
 
Serialserial ()
 Gives access to serial port in use. Used for other high and low level operations, eg. in OSTC Planner. More...
 
HardwareDescriptor hardwareDescriptor ()
 Ask the connect device for its hardware options. More...
 

Protected Types

enum  Mode {
  CLOSED_MODE = 0,
  DOWNLOAD_MODE,
  SERVICE_MODE
}
 

Protected Member Functions

void eraseRange (unsigned int addr, unsigned int size)
 Erase OSTC3 PROM memory. PROM memory should be erased beforeprogramming the new firmware. This command is used to erase a set of 4KB pages. More...
 
void writeBlock (unsigned int addr, const unsigned char *data, unsigned int size)
 Write a big block of bytes to OSTC3 RAM memory. More...
 
void readBlock (unsigned int addr, unsigned char *ptr, unsigned int size)
 Read-back a big block of bytes from OSTC3 RAM memory. More...
 
void upgradeFirmware (unsigned int checksum)
 Burn firmare. More...
 
virtual void getCommonIdentity ()
 
void connectServiceMode () override
 Open service mode communication to the dive computer. More...
 
- Protected Member Functions inherited from HardwareOperations
QStringList listBluetoothPorts () const
 List serial ports for Bluetooth based devices. More...
 
QStringList listUSBPorts () const
 List serial ports for USB based devices. More...
 

Protected Attributes

QString descriptionString
 
QString emulatorName
 
char computerText [60]
 
enum OSTC3Operations::Mode _connectMode
 
- Protected Attributes inherited from HardwareOperations
Serial _serial
 Communication port used for all I/O operations. More...
 

Additional Inherited Members

- Public Types inherited from HardwareOperations
enum  HardwareOption {
  HW_CHARGEABLE_BATTERY = 0x01,
  HW_LIGHT_SENSOR = 0x02,
  HW_S8_COM = 0x04,
  HW_OPTICAL_COM = 0x08,
  HW_BLUETOOTH_COM = 0x10,
  HW_DUALCORE = 0x20
}
 Optional features present in the dive computer hardware. More...
 
enum  HardwareDescriptor {
  HW_UNKNOWN_OSTC = 0,
  HW_Frog = HW_BLUETOOTH_COM,
  HW_OSTCSport_a = HW_LIGHT_SENSOR | HW_BLUETOOTH_COM,
  HW_OSTCSport_b = HW_OSTCSport_a | HW_CHARGEABLE_BATTERY,
  HW_OSTC2c = HW_CHARGEABLE_BATTERY,
  HW_OSTC2_a = HW_CHARGEABLE_BATTERY | HW_BLUETOOTH_COM,
  HW_OSTC2_b = HW_OSTCSport_b,
  HW_OSTC2_c = HW_OSTC2_b | HW_OPTICAL_COM,
  HW_OSTC3 = HW_LIGHT_SENSOR | HW_OPTICAL_COM,
  HW_OSTC3p_a = HW_LIGHT_SENSOR | HW_OPTICAL_COM | HW_BLUETOOTH_COM,
  HW_OSTC3p_b = HW_OSTCSport_b,
  HW_OSTCcR_a = HW_CHARGEABLE_BATTERY | HW_S8_COM,
  HW_OSTCcR_b = HW_OSTCcR_a | HW_LIGHT_SENSOR,
  HW_OSTC4
}
 Dive computer set of features. More...
 
enum  CompanionFeatures {
  PARAMETERS = (1<<0),
  DATE = (1<<1),
  NAME = (1<<2),
  ICON = (1<<3),
  DUMPSCREEN = (1<<4),
  FIRMWARE = (1<<5),
  HELIUM_DIVE = (1<<6),
  CCR_DIVE = (1<<7),
  BLUETOOTH = (1<<8),
  VPM_MODEL = (1<<9)
}
 Features supported by OSTC Companion on the connected device. More...
 
- Static Public Member Functions inherited from HardwareOperations
static EXPORT unsigned char retryCommand (Serial &serial, unsigned char cmd, int retries=10)
 Send a command, wait ack, and retry on error. More...
 

Detailed Description

Implementing various low-level operations for OSTC3 dive computer.

See also
OSTCSportOperations, OSTC2Operations, OSTC3pOperations, OSTC4Operations, OSTCcROperations.

Member Enumeration Documentation

enum OSTC3Operations::Mode
protected
Enumerator
CLOSED_MODE 

Not yet open.

DOWNLOAD_MODE 

Open in normal mode.

SERVICE_MODE 

Open in FIRMWARE UPGRADE mode.

Constructor & Destructor Documentation

OSTC3Operations::OSTC3Operations ( )
OSTC3Operations::~OSTC3Operations ( )

Member Function Documentation

bool OSTC3Operations::connect ( )
overridevirtual

low-level service mode commands.

Implements HardwareOperations.

void OSTC3Operations::connectServiceMode ( )
overrideprotectedvirtual

Open service mode communication to the dive computer.

Open comm port, start service mode, check the blessed reply.

Note
this mode is mandatory to allow upgradeFW().
Returns
TRUE is everything went well.
See also
connect() and disconnect().

Implements HardwareOperations.

QString OSTC3Operations::customText ( ) const
overridevirtual

The user-defined string found during the last getIdentty().

Implements HardwareOperations.

bool OSTC3Operations::disconnect ( bool  closing = false)
overridevirtual

Close connection.

Exit service mode, and close everything. closing should be set when ending Companion, so an error make a won't crash if the interface is already deleted.

Implements HardwareOperations.

QImage OSTC3Operations::dumpScreen ( ) const
overridevirtual

Take a snapshot of the connected computer's screen.

Currently only supported by OSTC mk2/2n/2c dive computers.

Implements HardwareOperations.

void OSTC3Operations::eraseRange ( unsigned int  addr,
unsigned int  size 
)
protected

Erase OSTC3 PROM memory. PROM memory should be erased beforeprogramming the new firmware. This command is used to erase a set of 4KB pages.

Parameters
[in]addrFirst address (24bits) to erase. Should be a multiple of 4096.
[in]sizeNumber of bytes to erase. Will be rounded (up) to a multiple of 4096.
Exceptions
ifsomething goes wrong.
int OSTC3Operations::firmware ( ) const
overridevirtual

The fw version found during the last getIdentty().

Implements HardwareOperations.

QString OSTC3Operations::firmwareTemplate ( ) const
overridevirtual

filename matching template for compatible firmware.

Used by the Upgrade Firmware... command to propose only firmwares designed for the connected device.

Implements HardwareOperations.

void OSTC3Operations::getCommonIdentity ( )
protectedvirtual
void OSTC3Operations::getIdentity ( )
overridevirtual

Read OSTC3 computer firmware, serial and custom text. Everything is formated for the description() string.

Exceptions
ifsomething goes wrong.

Implements HardwareOperations.

void OSTC3Operations::loadFirmware ( HexFile ,
const QString &  fileName 
) const
overridevirtual

Read in the specific firmware file format.

History is a bit complex here, and the published firmware have different file formats (due to support tool, and/or need for encryption). So each driver have to implement its specific loader.

Implements HardwareOperations.

QSize OSTC3Operations::nameSize ( ) const
overridevirtual

Custom text size (lines and columns).

low-level service mode commands.

Low level commands are used to directly speak to the OSTC3 firmware. They all throw an Exception if some error occurs.

Implements HardwareOperations.

void OSTC3Operations::readBlock ( unsigned int  addr,
unsigned char *  ptr,
unsigned int  size 
)
protected

Read-back a big block of bytes from OSTC3 RAM memory.

Parameters
[in]addrFirst address (24bits) to read from.
[in]ptr: Where to store bytes read.
[in]sizeNumber of bytes to read.
Exceptions
ifsomething goes wrong.
int OSTC3Operations::serialNumber ( ) const
overridevirtual

The serial number found during the last getIdentty().

Implements HardwareOperations.

void OSTC3Operations::setDate ( const QDateTime &  date)
overridevirtual

Set HW dive computer date and time.

Implements HardwareOperations.

void OSTC3Operations::setIcons ( const QString &  fileName)
overridevirtual

Set HW dive computer icon set.

Currently only supported by Frog dive computer.

Implements HardwareOperations.

void OSTC3Operations::setName ( const QString &  newName)
overridevirtual

Set HW dive computer user text.

Implements HardwareOperations.

void OSTC3Operations::upgradeFirmware ( unsigned int  checksum)
protected

Burn firmare.

Firmware should be first uploaded to RAM memory (

See also
writeBlock() ), in area 0x3E0000 .. 0x3FE000, then the firmware command will tell the OSTC3 to use that to reprogramm itself. A validation checksum is done to make sure a valid data have been uploaded.
Parameters
[in]checksumAdler32 checksum of the new firmware.
Exceptions
ifsomething goes wrong.
void OSTC3Operations::upgradeFW ( const QString &  fileName)
overridevirtual

Upgrade HW dive computer firmware.

Note
needs service mode connection.
See also
connectServiceMode().

Implements HardwareOperations.

void OSTC3Operations::writeBlock ( unsigned int  addr,
const unsigned char *  data,
unsigned int  size 
)
protected

Write a big block of bytes to OSTC3 RAM memory.

Parameters
[in]addrFirst address (24bits) to write to.
[in]dataBytes to write.
[in]sizeNumber of bytes to write.
Exceptions
ifsomething goes wrong.
void OSTC3Operations::writeText ( const QString &  msg)
overridevirtual

Display a short text on OSTC3 while on service mode. OSTC3 can handle 16 chars. So the string is automatically padded with spaces to clean any leftover.

Exceptions
ifsomething goes wrong.

Implements HardwareOperations.

Member Data Documentation

enum OSTC3Operations::Mode OSTC3Operations::_connectMode
protected
char OSTC3Operations::computerText[60]
protected
QString OSTC3Operations::descriptionString
protected
QString OSTC3Operations::emulatorName
protected

The documentation for this class was generated from the following files: