Skip to content

Commit

Permalink
In the win32 common code, if portname starts with 'C' insert the pref…
Browse files Browse the repository at this point in the history
…ix \\.\

[#6]
  • Loading branch information
jamesbowman committed Aug 30, 2018
1 parent 549a9c8 commit 28a289c
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion c/common/spidriver.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,15 @@ void ErrorExit(const char *func_name)

HANDLE openSerialPort(const char *portname)
{
char fullname[10];
const char *fmt;
if (portname[0] == 'C')
fmt = "\\\\.\\%s";
else
fmt == "%s";
snprintf(fullname, sizeof(fullname), fmt, portname);
DWORD accessdirection = GENERIC_READ | GENERIC_WRITE;
HANDLE hSerial = CreateFile((LPCSTR)portname,
HANDLE hSerial = CreateFile((LPCSTR)fullname,
accessdirection,
0,
0,
Expand Down

0 comments on commit 28a289c

Please sign in to comment.