Commit 35b707c953cb6821e18cdb7023bd3515f7b07f45
Committed by
Stéphane Raimbault
1 parent
c3993f15
Fix: CreateFile() does not set errno. Use GetLastError().
Showing
1 changed file
with
2 additions
and
2 deletions
src/modbus-rtu.c
| ... | ... | @@ -437,8 +437,8 @@ static int _modbus_rtu_connect(modbus_t *ctx) |
| 437 | 437 | |
| 438 | 438 | /* Error checking */ |
| 439 | 439 | if (ctx_rtu->w_ser.fd == INVALID_HANDLE_VALUE) { |
| 440 | - fprintf(stderr, "ERROR Can't open the device %s (%s)\n", | |
| 441 | - ctx_rtu->device, strerror(errno)); | |
| 440 | + fprintf(stderr, "ERROR Can't open the device %s (LastError %d)\n", | |
| 441 | + ctx_rtu->device, (int)GetLastError()); | |
| 442 | 442 | return -1; |
| 443 | 443 | } |
| 444 | 444 | ... | ... |