Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolas-rabault committed Aug 30, 2023
1 parent b5d4e75 commit 12a0584
Showing 1 changed file with 2 additions and 46 deletions.
48 changes: 2 additions & 46 deletions network/serial_network/HAL/NATIVE/serial_network_hal.c
Original file line number Diff line number Diff line change
Expand Up @@ -67,15 +67,6 @@ char *stripStr(char *string)
}

#ifdef _WIN32
void PrintCommState(DCB dcb)
{
// Print some of the DCB structure values
_tprintf(TEXT("\nBaudRate = %d, ByteSize = %d, Parity = %d, StopBits = %d\n"),
dcb.BaudRate,
dcb.ByteSize,
dcb.Parity,
dcb.StopBits);
}
void set_serial_raw_mode()
{
DCB dcb;
Expand All @@ -88,39 +79,21 @@ void set_serial_raw_mode()
LUOS_ASSERT(0);
return;
}
PrintCommState(dcb);

dcb.BaudRate
= CBR_115200; // SERIAL_NETWORK_BAUDRATE;
dcb.BaudRate = SERIAL_NETWORK_BAUDRATE;
dcb.ByteSize = 8;
dcb.StopBits = ONESTOPBIT;
dcb.Parity = NOPARITY;
dcb.fBinary = TRUE;
// dcb.fRtsControl = RTS_CONTROL_DISABLE;
// dcb.fOutxCtsFlow = FALSE;
// dcb.fDtrControl = DTR_CONTROL_DISABLE;
// dcb.fOutxDsrFlow = FALSE;
// dcb.fOutX = FALSE;
// dcb.fInX = FALSE;

if (!SetCommState(hSerial, &dcb))
{
printf("SetCommState failed with error %d.\n", GetLastError());
LUOS_ASSERT(0);
return;
}
PrintCommState(dcb);

if (!GetCommState(hSerial, &dcb))
{
printf("GetCommState failed with error %d.\n", GetLastError());
LUOS_ASSERT(0);
return;
}
PrintCommState(dcb);

COMMTIMEOUTS timeouts
= {0};
COMMTIMEOUTS timeouts = {0};
timeouts.ReadIntervalTimeout = MAXDWORD;
timeouts.ReadTotalTimeoutConstant = 0;
timeouts.ReadTotalTimeoutMultiplier = 0;
Expand All @@ -134,14 +107,6 @@ void set_serial_raw_mode()
return;
}

if (!GetCommState(hSerial, &dcb))
{
printf("GetCommState failed with error %d.\n", GetLastError());
LUOS_ASSERT(0);
return;
}
PrintCommState(dcb);

// Setup a 4k buffer
if (!SetupComm(hSerial, 4096, 4096))
{
Expand Down Expand Up @@ -383,15 +348,6 @@ void SerialHAL_Loop(void)
void SerialHAL_Send(uint8_t *data, uint16_t size)
{
#ifdef _WIN32
DWORD fileType = GetFileType(hSerial);
if (fileType == FILE_TYPE_UNKNOWN && GetLastError() == NO_ERROR)
{
printf("hSerial is an invalid handle\n");
}
else
{
printf("hSerial is a valid handle\n");
}
DWORD bytesWritten;
if (!WriteFile(hSerial, data, size, &bytesWritten, NULL))
{
Expand Down

0 comments on commit 12a0584

Please sign in to comment.