chg: more debug...

This commit is contained in:
iceman1001 2017-10-12 11:35:34 +02:00
commit 78ebac8e6f
2 changed files with 13 additions and 17 deletions

View file

@ -125,9 +125,6 @@ serial_port uart_open(const char* pcPortName)
}
void uart_close(const serial_port sp) {
// if (sp == INVALID_SERIAL_PORT) return;
// if (sp == CLAIMED_SERIAL_PORT) return;
serial_port_unix* spu = (serial_port_unix*)sp;
tcflush(spu->fd, TCIOFLUSH);
tcsetattr(spu->fd, TCSANOW, &(spu->tiOld));
@ -221,13 +218,13 @@ bool uart_send(const serial_port sp, const byte_t* pbtTx, const size_t szTxLen)
// Write error
if (res < 0) {
printf("UART:: write error\n");
printf("UART:: write error (%d)\n", res);
return false;
}
// Write time-out
if (res == 0) {
printf("UART:: write time-out\n");
printf("UART:: write time-out (%d)\n", res);
return false;
}
@ -236,7 +233,7 @@ bool uart_send(const serial_port sp, const byte_t* pbtTx, const size_t szTxLen)
// Stop if the OS has some troubles sending the data
if (res <= 0) {
printf("UART:: os troubles\n");
printf("UART:: os troubles (%d)\n", res);
return false;
}

View file

@ -111,25 +111,24 @@ serial_port uart_open(const char* pcPortName) {
}
void uart_close(const serial_port sp) {
// if (!sp) return;
// if (sp == INVALID_SERIAL_PORT) return;
// if (sp == CLAIMED_SERIAL_PORT) return;
if (((serial_port_windows*)sp)->hPort != INVALID_HANDLE_VALUE )
CloseHandle(((serial_port_windows*)sp)->hPort);
free(sp);
}
bool uart_receive(const serial_port sp, byte_t* pbtRx, size_t pszMaxRxLen, size_t* pszRxLen) {
ReadFile(((serial_port_windows*)sp)->hPort, pbtRx, pszMaxRxLen, (LPDWORD)pszRxLen, NULL);
return (*pszRxLen != 0);
bool uart_receive(const serial_port sp, byte_t* p_rx, size_t pszMaxRxLen, size_t* p_rxlen) {
ReadFile(((serial_port_windows*)sp)->hPort, p_rx, pszMaxRxLen, (LPDWORD)p_rxlen, NULL);
return (*p_rxlen != 0);
}
bool uart_send(const serial_port sp, const byte_t* pbtTx, const size_t szTxLen) {
DWORD dwTxLen = 0;
if ( !WriteFile(((serial_port_windows*)sp)->hPort, pbtTx, szTxLen, &dwTxLen, NULL) ) {
bool uart_send(const serial_port sp, const byte_t* p_tx, const size_t len) {
DWORD txlen = 0;
bool res = WriteFile(((serial_port_windows*)sp)->hPort, p_tx, len, &txlen, NULL);
if ( !res )
return false;
}
return (dwTxLen != 0);
printf("TX %u\n", txlen);
return (txlen != 0);
}
bool uart_set_speed(serial_port sp, const uint32_t uiPortSpeed) {