Implement the serial communication functions as no-ops
For the socket based I/O stream implementations (IrDA and bluetooth) the serial communication specific functions are meaningless. Implementing them as no-ops allows the dive computer backends the call the I/O stream functions unconditionally. This is important for the bluetooth implementation, because bluetooth enabled dive computers will be able to use both the native bluetooth communication and the legacy bluetooth serial port emulation.
This commit is contained in:
parent
823303980e
commit
e22ba69819
@ -65,19 +65,19 @@
|
||||
static const dc_iostream_vtable_t dc_bluetooth_vtable = {
|
||||
sizeof(dc_socket_t),
|
||||
dc_socket_set_timeout, /* set_timeout */
|
||||
NULL, /* set_latency */
|
||||
NULL, /* set_halfduplex */
|
||||
NULL, /* set_break */
|
||||
NULL, /* set_dtr */
|
||||
NULL, /* set_rts */
|
||||
NULL, /* get_lines */
|
||||
dc_socket_set_latency, /* set_latency */
|
||||
dc_socket_set_halfduplex, /* set_halfduplex */
|
||||
dc_socket_set_break, /* set_break */
|
||||
dc_socket_set_dtr, /* set_dtr */
|
||||
dc_socket_set_rts, /* set_rts */
|
||||
dc_socket_get_lines, /* get_lines */
|
||||
dc_socket_get_available, /* get_received */
|
||||
NULL, /* configure */
|
||||
dc_socket_configure, /* configure */
|
||||
dc_socket_read, /* read */
|
||||
dc_socket_write, /* write */
|
||||
NULL, /* flush */
|
||||
NULL, /* purge */
|
||||
NULL, /* sleep */
|
||||
dc_socket_flush, /* flush */
|
||||
dc_socket_purge, /* purge */
|
||||
dc_socket_sleep, /* sleep */
|
||||
dc_socket_close, /* close */
|
||||
};
|
||||
|
||||
|
||||
20
src/irda.c
20
src/irda.c
@ -56,19 +56,19 @@
|
||||
static const dc_iostream_vtable_t dc_irda_vtable = {
|
||||
sizeof(dc_socket_t),
|
||||
dc_socket_set_timeout, /* set_timeout */
|
||||
NULL, /* set_latency */
|
||||
NULL, /* set_halfduplex */
|
||||
NULL, /* set_break */
|
||||
NULL, /* set_dtr */
|
||||
NULL, /* set_rts */
|
||||
NULL, /* get_lines */
|
||||
dc_socket_set_latency, /* set_latency */
|
||||
dc_socket_set_halfduplex, /* set_halfduplex */
|
||||
dc_socket_set_break, /* set_break */
|
||||
dc_socket_set_dtr, /* set_dtr */
|
||||
dc_socket_set_rts, /* set_rts */
|
||||
dc_socket_get_lines, /* get_lines */
|
||||
dc_socket_get_available, /* get_received */
|
||||
NULL, /* configure */
|
||||
dc_socket_configure, /* configure */
|
||||
dc_socket_read, /* read */
|
||||
dc_socket_write, /* write */
|
||||
NULL, /* flush */
|
||||
NULL, /* purge */
|
||||
NULL, /* sleep */
|
||||
dc_socket_flush, /* flush */
|
||||
dc_socket_purge, /* purge */
|
||||
dc_socket_sleep, /* sleep */
|
||||
dc_socket_close, /* close */
|
||||
};
|
||||
#endif
|
||||
|
||||
63
src/socket.c
63
src/socket.c
@ -163,6 +163,45 @@ dc_socket_set_timeout (dc_iostream_t *abstract, int timeout)
|
||||
return DC_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
dc_status_t
|
||||
dc_socket_set_latency (dc_iostream_t *iostream, unsigned int value)
|
||||
{
|
||||
return DC_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
dc_status_t
|
||||
dc_socket_set_halfduplex (dc_iostream_t *iostream, unsigned int value)
|
||||
{
|
||||
return DC_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
dc_status_t
|
||||
dc_socket_set_break (dc_iostream_t *iostream, unsigned int value)
|
||||
{
|
||||
return DC_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
dc_status_t
|
||||
dc_socket_set_dtr (dc_iostream_t *iostream, unsigned int value)
|
||||
{
|
||||
return DC_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
dc_status_t
|
||||
dc_socket_set_rts (dc_iostream_t *iostream, unsigned int value)
|
||||
{
|
||||
return DC_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
dc_status_t
|
||||
dc_socket_get_lines (dc_iostream_t *iostream, unsigned int *value)
|
||||
{
|
||||
if (value)
|
||||
*value = 0;
|
||||
|
||||
return DC_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
dc_status_t
|
||||
dc_socket_get_available (dc_iostream_t *abstract, size_t *value)
|
||||
{
|
||||
@ -186,6 +225,12 @@ dc_socket_get_available (dc_iostream_t *abstract, size_t *value)
|
||||
return DC_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
dc_status_t
|
||||
dc_socket_configure (dc_iostream_t *abstract, unsigned int baudrate, unsigned int databits, dc_parity_t parity, dc_stopbits_t stopbits, dc_flowcontrol_t flowcontrol)
|
||||
{
|
||||
return DC_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
dc_status_t
|
||||
dc_socket_read (dc_iostream_t *abstract, void *data, size_t size, size_t *actual)
|
||||
{
|
||||
@ -293,3 +338,21 @@ out:
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
dc_status_t
|
||||
dc_socket_flush (dc_iostream_t *abstract)
|
||||
{
|
||||
return DC_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
dc_status_t
|
||||
dc_socket_purge (dc_iostream_t *abstract, dc_direction_t direction)
|
||||
{
|
||||
return DC_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
dc_status_t
|
||||
dc_socket_sleep (dc_iostream_t *abstract, unsigned int timeout)
|
||||
{
|
||||
return DC_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
33
src/socket.h
33
src/socket.h
@ -104,15 +104,48 @@ dc_socket_connect (dc_iostream_t *iostream, const struct sockaddr *addr, s_sockl
|
||||
dc_status_t
|
||||
dc_socket_set_timeout (dc_iostream_t *iostream, int timeout);
|
||||
|
||||
dc_status_t
|
||||
dc_socket_set_latency (dc_iostream_t *iostream, unsigned int value);
|
||||
|
||||
dc_status_t
|
||||
dc_socket_set_halfduplex (dc_iostream_t *iostream, unsigned int value);
|
||||
|
||||
dc_status_t
|
||||
dc_socket_set_break (dc_iostream_t *iostream, unsigned int value);
|
||||
|
||||
dc_status_t
|
||||
dc_socket_set_dtr (dc_iostream_t *iostream, unsigned int value);
|
||||
|
||||
dc_status_t
|
||||
dc_socket_set_rts (dc_iostream_t *iostream, unsigned int value);
|
||||
|
||||
dc_status_t
|
||||
dc_socket_get_lines (dc_iostream_t *iostream, unsigned int *value);
|
||||
|
||||
dc_status_t
|
||||
dc_socket_get_available (dc_iostream_t *iostream, size_t *value);
|
||||
|
||||
dc_status_t
|
||||
dc_socket_configure (dc_iostream_t *iostream, unsigned int baudrate, unsigned int databits, dc_parity_t parity, dc_stopbits_t stopbits, dc_flowcontrol_t flowcontrol);
|
||||
|
||||
dc_status_t
|
||||
dc_socket_read (dc_iostream_t *iostream, void *data, size_t size, size_t *actual);
|
||||
|
||||
dc_status_t
|
||||
dc_socket_write (dc_iostream_t *iostream, const void *data, size_t size, size_t *actual);
|
||||
|
||||
dc_status_t
|
||||
dc_socket_flush (dc_iostream_t *iostream);
|
||||
|
||||
dc_status_t
|
||||
dc_socket_purge (dc_iostream_t *iostream, dc_direction_t direction);
|
||||
|
||||
dc_status_t
|
||||
dc_socket_sleep (dc_iostream_t *iostream, unsigned int milliseconds);
|
||||
|
||||
dc_status_t
|
||||
dc_socket_close (dc_iostream_t *iostream);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user