Skip to content

Commit

Permalink
cleaning up typecasts
Browse files Browse the repository at this point in the history
  • Loading branch information
iceman1001 committed Sep 26, 2017
1 parent 08bf63c commit ee0409d
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions uart/uart_posix.c
Original file line number Diff line number Diff line change
Expand Up @@ -222,13 +222,14 @@ bool uart_send(const serial_port sp, const byte_t* pbtTx, const size_t szTxLen)
size_t szPos = 0;
fd_set rfds;
struct timeval tv;

const serial_port_unix* spu = (serial_port_unix*)sp;

while (szPos < szTxLen) {
// Reset file descriptor
FD_ZERO(&rfds);
FD_SET(((serial_port_unix*)sp)->fd, &rfds);
FD_SET((spu->fd, &rfds);
tv = timeout;
res = select(((serial_port_unix*)sp)->fd+1, NULL, &rfds, NULL, &tv);
res = select((spu->fd+1, NULL, &rfds, NULL, &tv);

// Write error
if (res < 0) {
Expand All @@ -243,7 +244,7 @@ bool uart_send(const serial_port sp, const byte_t* pbtTx, const size_t szTxLen)
}

// Send away the bytes
res = write(((serial_port_unix*)sp)->fd, pbtTx + szPos, szTxLen-szPos);
res = write(spu->fd, pbtTx + szPos, szTxLen-szPos);

// Stop if the OS has some troubles sending the data
if (res <= 0) {
Expand Down

0 comments on commit ee0409d

Please sign in to comment.