20     serial->hCom = INVALID_HANDLE_VALUE;
 
   29     COMMTIMEOUTS timeouts;
 
   30     GetCommTimeouts(serial->hCom, &timeouts);
 
   32     timeouts.ReadIntervalTimeout = (timeout == 0) ? MAXDWORD : 0;
 
   33     timeouts.ReadTotalTimeoutConstant = timeout;
 
   34     timeouts.ReadTotalTimeoutMultiplier = 0;
 
   36     SetCommTimeouts(serial->hCom, &timeouts);
 
   43     enum { NameLength = 11 };
 
   44     char adjusted_device[NameLength];
 
   49     _snprintf(adjusted_device, NameLength, 
"\\\\.\\%s", device);
 
   50     serial->hCom = CreateFileA(adjusted_device, GENERIC_READ | GENERIC_WRITE,
 
   51                                0, NULL, OPEN_EXISTING,
 
   52                                FILE_ATTRIBUTE_NORMAL, NULL);
 
   54     if (serial->hCom == INVALID_HANDLE_VALUE) {
 
   61     SetupComm(serial->hCom, 4096 * 8, 4096);
 
   70     serial->current_timeout = 0;
 
   79     if (serial->hCom != INVALID_HANDLE_VALUE) {
 
   80         CloseHandle(serial->hCom);
 
   81         serial->hCom = INVALID_HANDLE_VALUE;
 
   94         baudrate_value = CBR_4800;
 
   98         baudrate_value = CBR_9600;
 
  102         baudrate_value = CBR_19200;
 
  106         baudrate_value = CBR_38400;
 
  110         baudrate_value = CBR_57600;
 
  114         baudrate_value = CBR_115200;
 
  118         baudrate_value = baudrate;
 
  121     GetCommState(serial->hCom, &dcb);
 
  122     dcb.BaudRate = baudrate_value;
 
  124     dcb.Parity = NOPARITY;
 
  126     dcb.StopBits = ONESTOPBIT;
 
  127     SetCommState(serial->hCom, &dcb);
 
  141     if (serial->hCom == INVALID_HANDLE_VALUE) {
 
  145     WriteFile(serial->hCom, data, (DWORD)size, &n, NULL);
 
  156     if (timeout != serial->current_timeout) {
 
  158         serial->current_timeout = timeout;
 
  161     ReadFile(serial->hCom, &data[filled], (DWORD)max_size - filled, &n, NULL);
 
  184     if (serial->hCom == INVALID_HANDLE_VALUE) {
 
  192     read_n = max_size - filled;
 
  193     if (buffer_size < read_n) {
 
  204     if (read_n > buffer_size) {
 
  205         read_n = buffer_size;
 
  214                                max_size - filled, serial, timeout);