Skip to content

Commit 068eb4f

Browse files
committed
Include debug.h
1 parent 648509f commit 068eb4f

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

lib/hardware/COMChannel.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
#ifdef HELLO_IM_A_PC
44

5+
#include "../../include/debug.h"
6+
57
void COMChannel::begin(const ChannelConfig& conf)
68
{
79
if (_fd != INVALID_HANDLE_VALUE)
@@ -15,12 +17,11 @@ void COMChannel::begin(const ChannelConfig& conf)
1517
if (_device.empty())
1618
{
1719
Debug_println("Serial port is not configured!");
18-
suspend();
1920
return;
2021
}
2122

2223
Debug_printf("Setting up serial port %s\n", _device.c_str());
23-
_fd = CreateFile(_device,
24+
_fd = CreateFile(_device.c_str(),
2425
GENERIC_READ | GENERIC_WRITE,
2526
0,
2627
0,
@@ -61,7 +62,6 @@ void COMChannel::begin(const ChannelConfig& conf)
6162
// activate settings
6263
if (!SetCommState(_fd, &dcbSerialParams)){
6364
Debug_printf("SetCommState error: %d\n", GetLastError());
64-
suspend();
6565
return;
6666
}
6767

@@ -86,7 +86,7 @@ void COMChannel::updateFIFO()
8686
{
8787
COMSTAT cs;
8888

89-
if (_fd < 0)
89+
if (_fd == INVALID_HANDLE_VALUE)
9090
return;
9191

9292
if (!ClearCommError(_fd, NULL, &cs))
@@ -107,7 +107,7 @@ void COMChannel::updateFIFO()
107107
size_t COMChannel::dataOut(const void *buffer, size_t length)
108108
{
109109
DWORD txbytes;
110-
if (!WriteFile(_fd, buffer, (DWORD)size, &txbytes, NULL))
110+
if (!WriteFile(_fd, buffer, (DWORD) length, &txbytes, NULL))
111111
{
112112
Debug_printf("UART write() write error: %dn", GetLastError());
113113
}
@@ -116,7 +116,7 @@ size_t COMChannel::dataOut(const void *buffer, size_t length)
116116

117117
void COMChannel::flushOutput()
118118
{
119-
if (_fd >= 0)
119+
if (_fd != INVALID_HANDLE_VALUE)
120120
FlushFileBuffers(_fd);
121121
return;
122122
}
@@ -125,7 +125,7 @@ void COMChannel::setBaudrate(uint32_t newBaud)
125125
{
126126
Debug_printf("UART set_baudrate: %d\n", newBaud);
127127

128-
if (_fd < 0 || newBaud == _baud)
128+
if (_fd == INVALID_HANDLE_VALUE || newBaud == _baud)
129129
return;
130130

131131
_baud = newBaud;

0 commit comments

Comments
 (0)