My problem is that I have try and check with different port_name
like 7 or 14 or 25. It's not opening or process the serial data the handle simply matching with the if
condition and it is closing the handle. Is there any problem with the code?
void command_handler::start()
{
char port_name[] = "COM7:"; /* Name of the serial port */
serial_port = CreateFile(port_name, GENERIC_READ | GENERIC_WRITE, 0, 0, OPEN_EXISTING, 0, 0);
/* Make sure port was opened */
if (serial_port == INVALID_HANDLE_VALUE)
{
fprintf(stderr, "Error opening port\n");
printf("I'm here");
CloseHandle(serial_port);
exit(0);
}
set_up_serial_port(serial_port, baud_rate);
process_serial_data = false;
}