Require a serial handle for the sleep function.
This commit is contained in:
parent
c5105a3788
commit
3df5cb09d7
@ -230,7 +230,7 @@ hw_frog_device_open (dc_device_t **out, const char *name)
|
||||
}
|
||||
|
||||
// Make sure everything is in a sane state.
|
||||
serial_sleep (300);
|
||||
serial_sleep (device->port, 300);
|
||||
serial_flush (device->port, SERIAL_QUEUE_BOTH);
|
||||
|
||||
// Send the init command.
|
||||
|
||||
@ -158,7 +158,7 @@ hw_ostc_device_open (dc_device_t **out, const char *name)
|
||||
}
|
||||
|
||||
// Make sure everything is in a sane state.
|
||||
serial_sleep (100);
|
||||
serial_sleep (device->port, 100);
|
||||
serial_flush (device->port, SERIAL_QUEUE_BOTH);
|
||||
|
||||
*out = (dc_device_t*) device;
|
||||
|
||||
@ -135,7 +135,7 @@ mares_common_packet (mares_common_device_t *device, const unsigned char command[
|
||||
return DC_STATUS_CANCELLED;
|
||||
|
||||
if (device->delay) {
|
||||
serial_sleep (device->delay);
|
||||
serial_sleep (device->port, device->delay);
|
||||
}
|
||||
|
||||
// Send the command to the device.
|
||||
|
||||
@ -159,7 +159,7 @@ mares_darwin_device_open (dc_device_t **out, const char *name, unsigned int mode
|
||||
}
|
||||
|
||||
// Make sure everything is in a sane state.
|
||||
serial_sleep (100);
|
||||
serial_sleep (device->base.port, 100);
|
||||
serial_flush (device->base.port, SERIAL_QUEUE_BOTH);
|
||||
|
||||
// Override the base class values.
|
||||
|
||||
@ -219,7 +219,7 @@ mares_nemo_device_dump (dc_device_t *abstract, dc_buffer_t *buffer)
|
||||
return DC_STATUS_CANCELLED;
|
||||
|
||||
device_event_emit (abstract, DC_EVENT_WAITING, NULL);
|
||||
serial_sleep (100);
|
||||
serial_sleep (device->port, 100);
|
||||
}
|
||||
|
||||
// Receive the header of the package.
|
||||
|
||||
@ -268,7 +268,7 @@ oceanic_atom2_transfer (oceanic_atom2_device_t *device, const unsigned char comm
|
||||
return rc;
|
||||
|
||||
// Delay the next attempt.
|
||||
serial_sleep (100);
|
||||
serial_sleep (device->port, 100);
|
||||
serial_flush (device->port, SERIAL_QUEUE_INPUT);
|
||||
}
|
||||
|
||||
@ -352,7 +352,7 @@ oceanic_atom2_device_open (dc_device_t **out, const char *name)
|
||||
}
|
||||
|
||||
// Give the interface 100 ms to settle and draw power up.
|
||||
serial_sleep (100);
|
||||
serial_sleep (device->port, 100);
|
||||
|
||||
// Make sure everything is in a sane state.
|
||||
serial_flush (device->port, SERIAL_QUEUE_BOTH);
|
||||
|
||||
@ -144,7 +144,7 @@ oceanic_veo250_transfer (oceanic_veo250_device_t *device, const unsigned char co
|
||||
return rc;
|
||||
|
||||
// Delay the next attempt.
|
||||
serial_sleep (100);
|
||||
serial_sleep (device->port, 100);
|
||||
}
|
||||
|
||||
// Receive the answer of the dive computer.
|
||||
@ -273,7 +273,7 @@ oceanic_veo250_device_open (dc_device_t **out, const char *name)
|
||||
}
|
||||
|
||||
// Give the interface 100 ms to settle and draw power up.
|
||||
serial_sleep (100);
|
||||
serial_sleep (device->port, 100);
|
||||
|
||||
// Make sure everything is in a sane state.
|
||||
serial_flush (device->port, SERIAL_QUEUE_BOTH);
|
||||
@ -287,7 +287,7 @@ oceanic_veo250_device_open (dc_device_t **out, const char *name)
|
||||
}
|
||||
|
||||
// Delay the sending of the version command.
|
||||
serial_sleep (100);
|
||||
serial_sleep (device->port, 100);
|
||||
|
||||
// Switch the device from surface mode into download mode. Before sending
|
||||
// this command, the device needs to be in PC mode (manually activated by
|
||||
|
||||
@ -301,7 +301,7 @@ oceanic_vtpro_device_open (dc_device_t **out, const char *name)
|
||||
}
|
||||
|
||||
// Give the interface 100 ms to settle and draw power up.
|
||||
serial_sleep (100);
|
||||
serial_sleep (device->port, 100);
|
||||
|
||||
// Make sure everything is in a sane state.
|
||||
serial_flush (device->port, SERIAL_QUEUE_BOTH);
|
||||
|
||||
@ -277,7 +277,7 @@ reefnet_sensus_handshake (reefnet_sensus_device_t *device)
|
||||
// Wait at least 10 ms to ensures the data line is
|
||||
// clear before transmission from the host begins.
|
||||
|
||||
serial_sleep (10);
|
||||
serial_sleep (device->port, 10);
|
||||
|
||||
return DC_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
@ -246,7 +246,7 @@ reefnet_sensuspro_handshake (reefnet_sensuspro_device_t *device)
|
||||
devinfo.serial = array_uint16_le (handshake + 4);
|
||||
device_event_emit (&device->base, DC_EVENT_DEVINFO, &devinfo);
|
||||
|
||||
serial_sleep (10);
|
||||
serial_sleep (device->port, 10);
|
||||
|
||||
return DC_STATUS_SUCCESS;
|
||||
}
|
||||
@ -370,7 +370,7 @@ reefnet_sensuspro_device_write_interval (dc_device_t *abstract, unsigned char in
|
||||
if (rc != DC_STATUS_SUCCESS)
|
||||
return rc;
|
||||
|
||||
serial_sleep (10);
|
||||
serial_sleep (device->port, 10);
|
||||
|
||||
int n = serial_write (device->port, &interval, 1);
|
||||
if (n != 1) {
|
||||
|
||||
@ -394,7 +394,7 @@ reefnet_sensusultra_send (reefnet_sensusultra_device_t *device, unsigned short c
|
||||
// not accidentally buffered by the host and (mis)interpreted as part
|
||||
// of the next packet.
|
||||
|
||||
serial_sleep (250);
|
||||
serial_sleep (device->port, 250);
|
||||
serial_flush (device->port, SERIAL_QUEUE_BOTH);
|
||||
}
|
||||
|
||||
|
||||
@ -106,7 +106,7 @@ int serial_get_transmitted (serial_t *device);
|
||||
|
||||
int serial_get_line (serial_t *device, int line);
|
||||
|
||||
int serial_sleep (unsigned long timeout /* milliseconds */);
|
||||
int serial_sleep (serial_t *device, unsigned long timeout /* milliseconds */);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
@ -606,7 +606,7 @@ serial_write (serial_t *device, const void *data, unsigned int size)
|
||||
// The remaining time is rounded up to the nearest millisecond to
|
||||
// match the Windows implementation. The higher resolution is
|
||||
// pointless anyway, since we already added a fudge factor above.
|
||||
serial_sleep ((remaining + 999) / 1000);
|
||||
serial_sleep (device, (remaining + 999) / 1000);
|
||||
}
|
||||
}
|
||||
|
||||
@ -773,8 +773,11 @@ serial_get_line (serial_t *device, int line)
|
||||
|
||||
|
||||
int
|
||||
serial_sleep (unsigned long timeout)
|
||||
serial_sleep (serial_t *device, unsigned long timeout)
|
||||
{
|
||||
if (device == NULL)
|
||||
return -1;
|
||||
|
||||
struct timespec ts;
|
||||
ts.tv_sec = (timeout / 1000);
|
||||
ts.tv_nsec = (timeout % 1000) * 1000000;
|
||||
|
||||
@ -423,7 +423,7 @@ serial_write (serial_t *device, const void* data, unsigned int size)
|
||||
// The remaining time is rounded up to the nearest millisecond
|
||||
// because the Windows Sleep() function doesn't have a higher
|
||||
// resolution.
|
||||
serial_sleep ((remaining + 999) / 1000);
|
||||
serial_sleep (device, (remaining + 999) / 1000);
|
||||
}
|
||||
}
|
||||
|
||||
@ -601,8 +601,11 @@ serial_get_line (serial_t *device, int line)
|
||||
|
||||
|
||||
int
|
||||
serial_sleep (unsigned long timeout)
|
||||
serial_sleep (serial_t *device, unsigned long timeout)
|
||||
{
|
||||
if (device == NULL)
|
||||
return -1;
|
||||
|
||||
Sleep (timeout);
|
||||
|
||||
return 0;
|
||||
|
||||
@ -177,7 +177,7 @@ suunto_d9_device_open (dc_device_t **out, const char *name, unsigned int model)
|
||||
}
|
||||
|
||||
// Give the interface 100 ms to settle and draw power up.
|
||||
serial_sleep (100);
|
||||
serial_sleep (device->port, 100);
|
||||
|
||||
// Make sure everything is in a sane state.
|
||||
serial_flush (device->port, SERIAL_QUEUE_BOTH);
|
||||
|
||||
@ -149,7 +149,7 @@ suunto_vyper_device_open (dc_device_t **out, const char *name)
|
||||
}
|
||||
|
||||
// Give the interface 100 ms to settle and draw power up.
|
||||
serial_sleep (100);
|
||||
serial_sleep (device->port, 100);
|
||||
|
||||
// Make sure everything is in a sane state.
|
||||
serial_flush (device->port, SERIAL_QUEUE_BOTH);
|
||||
@ -198,7 +198,7 @@ suunto_vyper_device_set_delay (dc_device_t *abstract, unsigned int delay)
|
||||
static dc_status_t
|
||||
suunto_vyper_send (suunto_vyper_device_t *device, const unsigned char command[], unsigned int csize)
|
||||
{
|
||||
serial_sleep (device->delay);
|
||||
serial_sleep (device->port, device->delay);
|
||||
|
||||
// Set RTS to send the command.
|
||||
serial_set_rts (device->port, 1);
|
||||
@ -221,7 +221,7 @@ suunto_vyper_send (suunto_vyper_device_t *device, const unsigned char command[],
|
||||
// receive the reply before RTS is cleared. We have to wait some time
|
||||
// before clearing RTS (around 30ms). But if we wait too long (> 500ms),
|
||||
// the reply disappears again.
|
||||
serial_sleep (200);
|
||||
serial_sleep (device->port, 200);
|
||||
serial_flush (device->port, SERIAL_QUEUE_INPUT);
|
||||
|
||||
// Clear RTS to receive the reply.
|
||||
|
||||
@ -127,7 +127,7 @@ suunto_vyper2_device_open (dc_device_t **out, const char *name)
|
||||
}
|
||||
|
||||
// Give the interface 100 ms to settle and draw power up.
|
||||
serial_sleep (100);
|
||||
serial_sleep (device->port, 100);
|
||||
|
||||
// Make sure everything is in a sane state.
|
||||
serial_flush (device->port, SERIAL_QUEUE_BOTH);
|
||||
@ -173,7 +173,7 @@ suunto_vyper2_device_packet (dc_device_t *abstract, const unsigned char command[
|
||||
if (device_is_cancelled (abstract))
|
||||
return DC_STATUS_CANCELLED;
|
||||
|
||||
serial_sleep (0x190 + 0xC8);
|
||||
serial_sleep (device->port, 600);
|
||||
|
||||
// Set RTS to send the command.
|
||||
serial_set_rts (device->port, 1);
|
||||
|
||||
@ -372,7 +372,7 @@ uwatec_memomouse_dump_internal (uwatec_memomouse_device_t *device, dc_buffer_t *
|
||||
return EXITCODE (n);
|
||||
}
|
||||
|
||||
serial_sleep (300);
|
||||
serial_sleep (device->port, 300);
|
||||
}
|
||||
|
||||
// Read the ID string.
|
||||
@ -395,7 +395,7 @@ uwatec_memomouse_dump_internal (uwatec_memomouse_device_t *device, dc_buffer_t *
|
||||
|
||||
// Wait a small amount of time before sending the command.
|
||||
// Without this delay, the transfer will fail most of the time.
|
||||
serial_sleep (50);
|
||||
serial_sleep (device->port, 50);
|
||||
|
||||
// Keep send the command to the device,
|
||||
// until the ACK answer is received.
|
||||
@ -431,7 +431,7 @@ uwatec_memomouse_dump_internal (uwatec_memomouse_device_t *device, dc_buffer_t *
|
||||
return DC_STATUS_CANCELLED;
|
||||
|
||||
device_event_emit (&device->base, DC_EVENT_WAITING, NULL);
|
||||
serial_sleep (100);
|
||||
serial_sleep (device->port, 100);
|
||||
}
|
||||
|
||||
// Fetch the current system time.
|
||||
@ -472,7 +472,7 @@ uwatec_memomouse_device_dump (dc_device_t *abstract, dc_buffer_t *buffer)
|
||||
|
||||
// Give the interface some time to notice the DTR
|
||||
// line change from a previous transfer (if any).
|
||||
serial_sleep (500);
|
||||
serial_sleep (device->port, 500);
|
||||
|
||||
// Set the DTR line.
|
||||
if (serial_set_dtr (device->port, 1) == -1) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user