Remove some unnecessary helper functions.

This commit is contained in:
Jef Driesen 2012-07-13 21:34:17 +02:00
parent 2a72da59ad
commit 83f742080b
3 changed files with 16 additions and 36 deletions

View File

@ -108,8 +108,6 @@ int serial_get_line (serial_t *device, int line);
int serial_sleep (unsigned long timeout /* milliseconds */);
int serial_timer (void);
#ifdef __cplusplus
}
#endif /* __cplusplus */

View File

@ -675,12 +675,16 @@ serial_set_break (serial_t *device, int level)
}
static int
serial_set_status (int fd, int value, int level)
int
serial_set_dtr (serial_t *device, int level)
{
if (device == NULL)
return -1; // EINVAL (Invalid argument)
unsigned long action = (level ? TIOCMBIS : TIOCMBIC);
if (ioctl (fd, action, &value) != 0) {
int value = TIOCM_DTR;
if (ioctl (device->fd, action, &value) != 0) {
TRACE ("ioctl");
return -1;
}
@ -689,23 +693,21 @@ serial_set_status (int fd, int value, int level)
}
int
serial_set_dtr (serial_t *device, int level)
{
if (device == NULL)
return -1; // EINVAL (Invalid argument)
return serial_set_status (device->fd, TIOCM_DTR, level);
}
int
serial_set_rts (serial_t *device, int level)
{
if (device == NULL)
return -1; // EINVAL (Invalid argument)
return serial_set_status (device->fd, TIOCM_RTS, level);
unsigned long action = (level ? TIOCMBIS : TIOCMBIC);
int value = TIOCM_RTS;
if (ioctl (device->fd, action, &value) != 0) {
TRACE ("ioctl");
return -1;
}
return 0;
}
@ -786,16 +788,3 @@ serial_sleep (unsigned long timeout)
return 0;
}
int
serial_timer (void)
{
struct timeval tv;
if (gettimeofday (&tv, NULL) != 0) {
TRACE ("gettimeofday");
return 0;
}
return tv.tv_sec * 1000 + tv.tv_usec / 1000;
}

View File

@ -607,10 +607,3 @@ serial_sleep (unsigned long timeout)
return 0;
}
int
serial_timer (void)
{
return GetTickCount ();
}