1
0
mirror of git://sigrok.org/libserialport synced 2023-08-10 21:13:24 +03:00

Add sp_start_break() and sp_end_break() functions.

This commit is contained in:
Martin Ling 2013-11-20 18:11:17 +00:00 committed by Bert Vermeulen
parent 69a3739ca0
commit 90cc3ee62b
2 changed files with 50 additions and 0 deletions

View File

@ -534,6 +534,28 @@ enum sp_return sp_flush(struct sp_port *port, enum sp_buffer buffers);
*/ */
enum sp_return sp_drain(struct sp_port *port); enum sp_return sp_drain(struct sp_port *port);
/**
* @}
* @defgroup Signal Port signalling operations
* @{
*/
/**
* Put the port transmit line into the break state.
*
* @return SP_OK on success, SP_ERR_FAIL on failure, or SP_ERR_ARG
* if an invalid port is passed.
*/
enum sp_return sp_start_break(struct sp_port *port);
/**
* Take the port transmit line out of the break state.
*
* @return SP_OK on success, SP_ERR_FAIL on failure, or SP_ERR_ARG
* if an invalid port is passed.
*/
enum sp_return sp_end_break(struct sp_port *port);
/** /**
* @} * @}
* @defgroup Errors Obtaining error information * @defgroup Errors Obtaining error information

View File

@ -1298,6 +1298,34 @@ enum sp_return sp_set_flowcontrol(struct sp_port *port, enum sp_flowcontrol flow
return SP_OK; return SP_OK;
} }
enum sp_return sp_start_break(struct sp_port *port)
{
CHECK_PORT();
#ifdef _WIN32
if (SetCommBreak(port->hdl) == 0)
return SP_ERR_FAIL;
#else
if (ioctl(port->fd, TIOCSBRK, 1) < 0)
return SP_ERR_FAIL;
#endif
return SP_OK;
}
enum sp_return sp_end_break(struct sp_port *port)
{
CHECK_PORT();
#ifdef _WIN32
if (ClearCommBreak(port->hdl) == 0)
return SP_ERR_FAIL;
#else
if (ioctl(port->fd, TIOCCBRK, 1) < 0)
return SP_ERR_FAIL;
#endif
return SP_OK;
}
int sp_last_error_code(void) int sp_last_error_code(void)
{ {
#ifdef _WIN32 #ifdef _WIN32