Remove a number of unnecessary functions.
This commit is contained in:
parent
a14b0b7b98
commit
87236f505a
@ -85,18 +85,6 @@ device_is_oceanic_atom2 (device_t *abstract)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static device_status_t
|
|
||||||
oceanic_atom2_send (oceanic_atom2_device_t *device, const unsigned char command[], unsigned int csize)
|
|
||||||
{
|
|
||||||
// Send the command to the dive computer and
|
|
||||||
// wait until all data has been transmitted.
|
|
||||||
serial_write (device->port, command, csize);
|
|
||||||
serial_drain (device->port);
|
|
||||||
|
|
||||||
return DEVICE_STATUS_SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static device_status_t
|
static device_status_t
|
||||||
oceanic_atom2_transfer (oceanic_atom2_device_t *device, const unsigned char command[], unsigned int csize, unsigned char answer[], unsigned int asize)
|
oceanic_atom2_transfer (oceanic_atom2_device_t *device, const unsigned char command[], unsigned int csize, unsigned char answer[], unsigned int asize)
|
||||||
{
|
{
|
||||||
@ -110,14 +98,14 @@ oceanic_atom2_transfer (oceanic_atom2_device_t *device, const unsigned char comm
|
|||||||
unsigned char response = NAK;
|
unsigned char response = NAK;
|
||||||
while (response == NAK) {
|
while (response == NAK) {
|
||||||
// Send the command to the dive computer.
|
// Send the command to the dive computer.
|
||||||
device_status_t rc = oceanic_atom2_send (device, command, csize);
|
int n = serial_write (device->port, command, csize);
|
||||||
if (rc != DEVICE_STATUS_SUCCESS) {
|
if (n != csize) {
|
||||||
WARNING ("Failed to send the command.");
|
WARNING ("Failed to send the command.");
|
||||||
return rc;
|
return EXITCODE (n);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Receive the response (ACK/NAK) of the dive computer.
|
// Receive the response (ACK/NAK) of the dive computer.
|
||||||
int n = serial_read (device->port, &response, 1);
|
n = serial_read (device->port, &response, 1);
|
||||||
if (n != 1) {
|
if (n != 1) {
|
||||||
WARNING ("Failed to receive the answer.");
|
WARNING ("Failed to receive the answer.");
|
||||||
return EXITCODE (n);
|
return EXITCODE (n);
|
||||||
@ -165,15 +153,15 @@ oceanic_atom2_init (oceanic_atom2_device_t *device)
|
|||||||
{
|
{
|
||||||
// Send the command to the dive computer.
|
// Send the command to the dive computer.
|
||||||
unsigned char command[3] = {0xA8, 0x99, 0x00};
|
unsigned char command[3] = {0xA8, 0x99, 0x00};
|
||||||
device_status_t rc = oceanic_atom2_send (device, command, sizeof (command));
|
int n = serial_write (device->port, command, sizeof (command));
|
||||||
if (rc != DEVICE_STATUS_SUCCESS) {
|
if (n != sizeof (command)) {
|
||||||
WARNING ("Failed to send the command.");
|
WARNING ("Failed to send the command.");
|
||||||
return rc;
|
return EXITCODE (n);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Receive the answer of the dive computer.
|
// Receive the answer of the dive computer.
|
||||||
unsigned char answer[3] = {0};
|
unsigned char answer[3] = {0};
|
||||||
int n = serial_read (device->port, answer, sizeof (answer));
|
n = serial_read (device->port, answer, sizeof (answer));
|
||||||
if (n != sizeof (answer)) {
|
if (n != sizeof (answer)) {
|
||||||
WARNING ("Failed to receive the answer.");
|
WARNING ("Failed to receive the answer.");
|
||||||
return EXITCODE (n);
|
return EXITCODE (n);
|
||||||
@ -194,15 +182,15 @@ oceanic_atom2_quit (oceanic_atom2_device_t *device)
|
|||||||
{
|
{
|
||||||
// Send the command to the dive computer.
|
// Send the command to the dive computer.
|
||||||
unsigned char command[4] = {0x6A, 0x05, 0xA5, 0x00};
|
unsigned char command[4] = {0x6A, 0x05, 0xA5, 0x00};
|
||||||
device_status_t rc = oceanic_atom2_send (device, command, sizeof (command));
|
int n = serial_write (device->port, command, sizeof (command));
|
||||||
if (rc != DEVICE_STATUS_SUCCESS) {
|
if (n != sizeof (command)) {
|
||||||
WARNING ("Failed to send the command.");
|
WARNING ("Failed to send the command.");
|
||||||
return rc;
|
return EXITCODE (n);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Receive the answer of the dive computer.
|
// Receive the answer of the dive computer.
|
||||||
unsigned char answer[1] = {0};
|
unsigned char answer[1] = {0};
|
||||||
int n = serial_read (device->port, answer, sizeof (answer));
|
n = serial_read (device->port, answer, sizeof (answer));
|
||||||
if (n != sizeof (answer)) {
|
if (n != sizeof (answer)) {
|
||||||
WARNING ("Failed to receive the answer.");
|
WARNING ("Failed to receive the answer.");
|
||||||
return EXITCODE (n);
|
return EXITCODE (n);
|
||||||
|
|||||||
@ -86,21 +86,6 @@ device_is_oceanic_veo250 (device_t *abstract)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static device_status_t
|
|
||||||
oceanic_veo250_send (oceanic_veo250_device_t *device, const unsigned char command[], unsigned int csize)
|
|
||||||
{
|
|
||||||
// Discard garbage bytes.
|
|
||||||
serial_flush (device->port, SERIAL_QUEUE_INPUT);
|
|
||||||
|
|
||||||
// Send the command to the dive computer and
|
|
||||||
// wait until all data has been transmitted.
|
|
||||||
serial_write (device->port, command, csize);
|
|
||||||
serial_drain (device->port);
|
|
||||||
|
|
||||||
return DEVICE_STATUS_SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static device_status_t
|
static device_status_t
|
||||||
oceanic_veo250_transfer (oceanic_veo250_device_t *device, const unsigned char command[], unsigned int csize, unsigned char answer[], unsigned int asize)
|
oceanic_veo250_transfer (oceanic_veo250_device_t *device, const unsigned char command[], unsigned int csize, unsigned char answer[], unsigned int asize)
|
||||||
{
|
{
|
||||||
@ -113,15 +98,18 @@ oceanic_veo250_transfer (oceanic_veo250_device_t *device, const unsigned char co
|
|||||||
unsigned int nretries = 0;
|
unsigned int nretries = 0;
|
||||||
unsigned char response = NAK;
|
unsigned char response = NAK;
|
||||||
while (response == NAK) {
|
while (response == NAK) {
|
||||||
|
// Discard garbage bytes.
|
||||||
|
serial_flush (device->port, SERIAL_QUEUE_INPUT);
|
||||||
|
|
||||||
// Send the command to the dive computer.
|
// Send the command to the dive computer.
|
||||||
device_status_t rc = oceanic_veo250_send (device, command, csize);
|
int n = serial_write (device->port, command, csize);
|
||||||
if (rc != DEVICE_STATUS_SUCCESS) {
|
if (n != csize) {
|
||||||
WARNING ("Failed to send the command.");
|
WARNING ("Failed to send the command.");
|
||||||
return rc;
|
return EXITCODE (n);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Receive the response (ACK/NAK) of the dive computer.
|
// Receive the response (ACK/NAK) of the dive computer.
|
||||||
int n = serial_read (device->port, &response, 1);
|
n = serial_read (device->port, &response, 1);
|
||||||
if (n != 1) {
|
if (n != 1) {
|
||||||
WARNING ("Failed to receive the answer.");
|
WARNING ("Failed to receive the answer.");
|
||||||
return EXITCODE (n);
|
return EXITCODE (n);
|
||||||
@ -165,15 +153,15 @@ oceanic_veo250_init (oceanic_veo250_device_t *device)
|
|||||||
{
|
{
|
||||||
// Send the command to the dive computer.
|
// Send the command to the dive computer.
|
||||||
unsigned char command[2] = {0x55, 0x00};
|
unsigned char command[2] = {0x55, 0x00};
|
||||||
device_status_t rc = oceanic_veo250_send (device, command, sizeof (command));
|
int n = serial_write (device->port, command, sizeof (command));
|
||||||
if (rc != DEVICE_STATUS_SUCCESS) {
|
if (n != sizeof (command)) {
|
||||||
WARNING ("Failed to send the command.");
|
WARNING ("Failed to send the command.");
|
||||||
return rc;
|
return EXITCODE (n);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Receive the answer of the dive computer.
|
// Receive the answer of the dive computer.
|
||||||
unsigned char answer[14] = {0};
|
unsigned char answer[14] = {0};
|
||||||
int n = serial_read (device->port, answer, sizeof (answer));
|
n = serial_read (device->port, answer, sizeof (answer));
|
||||||
if (n != sizeof (answer)) {
|
if (n != sizeof (answer)) {
|
||||||
WARNING ("Failed to receive the answer.");
|
WARNING ("Failed to receive the answer.");
|
||||||
return EXITCODE (n);
|
return EXITCODE (n);
|
||||||
@ -197,10 +185,10 @@ oceanic_veo250_quit (oceanic_veo250_device_t *device)
|
|||||||
{
|
{
|
||||||
// Send the command to the dive computer.
|
// Send the command to the dive computer.
|
||||||
unsigned char command[2] = {0x98, 0x00};
|
unsigned char command[2] = {0x98, 0x00};
|
||||||
device_status_t rc = oceanic_veo250_send (device, command, sizeof (command));
|
int n = serial_write (device->port, command, sizeof (command));
|
||||||
if (rc != DEVICE_STATUS_SUCCESS) {
|
if (n != sizeof (command)) {
|
||||||
WARNING ("Failed to send the command.");
|
WARNING ("Failed to send the command.");
|
||||||
return rc;
|
return EXITCODE (n);
|
||||||
}
|
}
|
||||||
|
|
||||||
return DEVICE_STATUS_SUCCESS;
|
return DEVICE_STATUS_SUCCESS;
|
||||||
|
|||||||
@ -86,18 +86,6 @@ device_is_oceanic_vtpro (device_t *abstract)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static device_status_t
|
|
||||||
oceanic_vtpro_send (oceanic_vtpro_device_t *device, const unsigned char command[], unsigned int csize)
|
|
||||||
{
|
|
||||||
// Send the command to the dive computer and
|
|
||||||
// wait until all data has been transmitted.
|
|
||||||
serial_write (device->port, command, csize);
|
|
||||||
serial_drain (device->port);
|
|
||||||
|
|
||||||
return DEVICE_STATUS_SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static device_status_t
|
static device_status_t
|
||||||
oceanic_vtpro_transfer (oceanic_vtpro_device_t *device, const unsigned char command[], unsigned int csize, unsigned char answer[], unsigned int asize)
|
oceanic_vtpro_transfer (oceanic_vtpro_device_t *device, const unsigned char command[], unsigned int csize, unsigned char answer[], unsigned int asize)
|
||||||
{
|
{
|
||||||
@ -111,14 +99,14 @@ oceanic_vtpro_transfer (oceanic_vtpro_device_t *device, const unsigned char comm
|
|||||||
unsigned char response = NAK;
|
unsigned char response = NAK;
|
||||||
while (response == NAK) {
|
while (response == NAK) {
|
||||||
// Send the command to the dive computer.
|
// Send the command to the dive computer.
|
||||||
device_status_t rc = oceanic_vtpro_send (device, command, csize);
|
int n = serial_write (device->port, command, csize);
|
||||||
if (rc != DEVICE_STATUS_SUCCESS) {
|
if (n != csize) {
|
||||||
WARNING ("Failed to send the command.");
|
WARNING ("Failed to send the command.");
|
||||||
return rc;
|
return EXITCODE (n);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Receive the response (ACK/NAK) of the dive computer.
|
// Receive the response (ACK/NAK) of the dive computer.
|
||||||
int n = serial_read (device->port, &response, 1);
|
n = serial_read (device->port, &response, 1);
|
||||||
if (n != 1) {
|
if (n != 1) {
|
||||||
WARNING ("Failed to receive the answer.");
|
WARNING ("Failed to receive the answer.");
|
||||||
return EXITCODE (n);
|
return EXITCODE (n);
|
||||||
@ -156,15 +144,15 @@ oceanic_vtpro_init (oceanic_vtpro_device_t *device)
|
|||||||
{
|
{
|
||||||
// Send the command to the dive computer.
|
// Send the command to the dive computer.
|
||||||
unsigned char command[2] = {0xAA, 0x00};
|
unsigned char command[2] = {0xAA, 0x00};
|
||||||
device_status_t rc = oceanic_vtpro_send (device, command, sizeof (command));
|
int n = serial_write (device->port, command, sizeof (command));
|
||||||
if (rc != DEVICE_STATUS_SUCCESS) {
|
if (n != sizeof (command)) {
|
||||||
WARNING ("Failed to send the command.");
|
WARNING ("Failed to send the command.");
|
||||||
return rc;
|
return EXITCODE (n);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Receive the answer of the dive computer.
|
// Receive the answer of the dive computer.
|
||||||
unsigned char answer[13] = {0};
|
unsigned char answer[13] = {0};
|
||||||
int n = serial_read (device->port, answer, sizeof (answer));
|
n = serial_read (device->port, answer, sizeof (answer));
|
||||||
if (n != sizeof (answer)) {
|
if (n != sizeof (answer)) {
|
||||||
WARNING ("Failed to receive the answer.");
|
WARNING ("Failed to receive the answer.");
|
||||||
return EXITCODE (n);
|
return EXITCODE (n);
|
||||||
|
|||||||
@ -195,22 +195,6 @@ uwatec_memomouse_device_set_fingerprint (device_t *abstract, const unsigned char
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static device_status_t
|
|
||||||
uwatec_memomouse_confirm (uwatec_memomouse_device_t *device, unsigned char value)
|
|
||||||
{
|
|
||||||
// Send the value to the device.
|
|
||||||
int rc = serial_write (device->port, &value, 1);
|
|
||||||
if (rc != 1) {
|
|
||||||
WARNING ("Failed to send the value.");
|
|
||||||
return EXITCODE (rc);
|
|
||||||
}
|
|
||||||
|
|
||||||
serial_drain (device->port);
|
|
||||||
|
|
||||||
return DEVICE_STATUS_SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static device_status_t
|
static device_status_t
|
||||||
uwatec_memomouse_read_packet (uwatec_memomouse_device_t *device, unsigned char data[], unsigned int size, unsigned int *result)
|
uwatec_memomouse_read_packet (uwatec_memomouse_device_t *device, unsigned char data[], unsigned int size, unsigned int *result)
|
||||||
{
|
{
|
||||||
@ -271,9 +255,12 @@ uwatec_memomouse_read_packet_outer (uwatec_memomouse_device_t *device, unsigned
|
|||||||
serial_flush (device->port, SERIAL_QUEUE_INPUT);
|
serial_flush (device->port, SERIAL_QUEUE_INPUT);
|
||||||
|
|
||||||
// Reject the packet.
|
// Reject the packet.
|
||||||
rc = uwatec_memomouse_confirm (device, NAK);
|
unsigned char value = NAK;
|
||||||
if (rc != DEVICE_STATUS_SUCCESS)
|
int n = serial_write (device->port, &value, 1);
|
||||||
return rc;
|
if (n != 1) {
|
||||||
|
WARNING ("Failed to reject the packet.");
|
||||||
|
return EXITCODE (n);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return DEVICE_STATUS_SUCCESS;
|
return DEVICE_STATUS_SUCCESS;
|
||||||
@ -304,9 +291,12 @@ uwatec_memomouse_read_packet_inner (uwatec_memomouse_device_t *device, dc_buffer
|
|||||||
return rc;
|
return rc;
|
||||||
|
|
||||||
// Accept the packet.
|
// Accept the packet.
|
||||||
rc = uwatec_memomouse_confirm (device, ACK);
|
unsigned char value = ACK;
|
||||||
if (rc != DEVICE_STATUS_SUCCESS)
|
int n = serial_write (device->port, &value, 1);
|
||||||
return rc;
|
if (n != 1) {
|
||||||
|
WARNING ("Failed to accept the packet.");
|
||||||
|
return EXITCODE (n);
|
||||||
|
}
|
||||||
|
|
||||||
if (nbytes == 0) {
|
if (nbytes == 0) {
|
||||||
// The first packet should contain at least
|
// The first packet should contain at least
|
||||||
@ -370,9 +360,12 @@ uwatec_memomouse_dump_internal (uwatec_memomouse_device_t *device, dc_buffer_t *
|
|||||||
serial_flush (device->port, SERIAL_QUEUE_INPUT);
|
serial_flush (device->port, SERIAL_QUEUE_INPUT);
|
||||||
|
|
||||||
// Reject the packet.
|
// Reject the packet.
|
||||||
device_status_t rc = uwatec_memomouse_confirm (device, NAK);
|
unsigned char value = NAK;
|
||||||
if (rc != DEVICE_STATUS_SUCCESS)
|
int n = serial_write (device->port, &value, 1);
|
||||||
return rc;
|
if (n != 1) {
|
||||||
|
WARNING ("Failed to reject the packet.");
|
||||||
|
return EXITCODE (n);
|
||||||
|
}
|
||||||
|
|
||||||
serial_sleep (300);
|
serial_sleep (300);
|
||||||
}
|
}
|
||||||
@ -413,8 +406,6 @@ uwatec_memomouse_dump_internal (uwatec_memomouse_device_t *device, dc_buffer_t *
|
|||||||
return EXITCODE (n);
|
return EXITCODE (n);
|
||||||
}
|
}
|
||||||
|
|
||||||
serial_drain (device->port);
|
|
||||||
|
|
||||||
// Wait for the answer (ACK).
|
// Wait for the answer (ACK).
|
||||||
n = serial_read (device->port, &answer, 1);
|
n = serial_read (device->port, &answer, 1);
|
||||||
if (n != 1) {
|
if (n != 1) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user