Главная страница
Top.Mail.Ru    Яндекс.Метрика
Текущий архив: 2006.12.31;
Скачать: CL | DM;

Вниз

Вопрос по структуре DCB при работе с СОМ портом   Найти похожие ветки 

 
Андрей Пл   (2006-08-19 09:42) [0]

Прошу подсказать следующее:
в хелпе я нашел описание структуры DCB:
typedef struct _DCB { // dcb  
   DWORD DCBlength;           // sizeof(DCB)
   DWORD BaudRate;            // current baud rate
   DWORD fBinary: 1;          // binary mode, no EOF check
   DWORD fParity: 1;          // enable parity checking
   DWORD fOutxCtsFlow:1;      // CTS output flow control
   DWORD fOutxDsrFlow:1;      // DSR output flow control
   DWORD fDtrControl:2;       // DTR flow control type
   DWORD fDsrSensitivity:1;   // DSR sensitivity

   DWORD fTXContinueOnXoff:1; // XOFF continues Tx
   DWORD fOutX: 1;            // XON/XOFF out flow control
   DWORD fInX: 1;             // XON/XOFF in flow control
   DWORD fErrorChar: 1;       // enable error replacement
   DWORD fNull: 1;            // enable null stripping
   DWORD fRtsControl:2;       // RTS flow control
   DWORD fAbortOnError:1;     // abort reads/writes on error
   DWORD fDummy2:17;          // reserved
   WORD wReserved;            // not currently used

   WORD XonLim;               // transmit XON threshold
   WORD XoffLim;              // transmit XOFF threshold
   BYTE ByteSize;             // number of bits/byte, 4-8
   BYTE Parity;               // 0-4=no,odd,even,mark,space
   BYTE StopBits;             // 0,1,2 = 1, 1.5, 2
   char XonChar;              // Tx and Rx XON character
   char XoffChar;             // Tx and Rx XOFF character
   char ErrorChar;            // error replacement character

   char EofChar;              // end of input character
   char EvtChar;              // received event character
   WORD wReserved1;           // reserved; do not use
} DCB;


реально описано:

 _DCB = packed record
   DCBlength: DWORD;
   BaudRate: DWORD;
   Flags: Longint;
   wReserved: Word;
   XonLim: Word;
   XoffLim: Word;
   ByteSize: Byte;
   Parity: Byte;
   StopBits: Byte;
   XonChar: CHAR;
   XoffChar: CHAR;
   ErrorChar: CHAR;
   EofChar: CHAR;
   EvtChar: CHAR;
   wReserved1: Word;
 end;


значит битовые поля
  DWORD fBinary: 1;          // binary mode, no EOF check
   DWORD fParity: 1;          // enable parity checking
   DWORD fOutxCtsFlow:1;      // CTS output flow control
   DWORD fOutxDsrFlow:1;      // DSR output flow control
   DWORD fDtrControl:2;       // DTR flow control type
   DWORD fDsrSensitivity:1;   // DSR sensitivity
   DWORD fTXContinueOnXoff:1; // XOFF continues Tx
   DWORD fOutX: 1;            // XON/XOFF out flow control
   DWORD fInX: 1;             // XON/XOFF in flow control
   DWORD fErrorChar: 1;       // enable error replacement
   DWORD fNull: 1;            // enable null stripping
   DWORD fRtsControl:2;       // RTS flow control
   DWORD fAbortOnError:1;     // abort reads/writes on error
   DWORD fDummy2:17;          // reserved    WORD

размещены в одном поле
Flags: Longint
Вопрос:  Как мне установить одноиз битовых полей - допустим поле fRtsControl в значение RTS_CONTROL_TOGGLE


 
medved_68 ©   (2006-08-20 15:07) [1]

Андрей Пл    На чем работаешь??? Если Delphi то см. класс TDCB, поле TDCB.Flags. Битовые маски хлопаются обычным OR

> Вопрос:  Как мне установить одно из битовых полей - допустим
> поле fRtsControl в значение RTS_CONTROL_TOGGLE


var
 DR:TDCB;
begin
//Открываем порт
GetCommState(HCom,DR);
DR.Flags:=DR.Flags or $3000
//Это и будет RTS_CONTROL_TOGGLE
//Если нужны другие значения то хлопаем $0000 - $2000
//По умолчанию RTS_CONTROL_HANDSHAKE
SetCommState(HCom,DR);
И все!!! 8:)))


 
Андрей Пл   (2006-08-22 15:33) [2]

спасибо получилось!



Страницы: 1 вся ветка

Текущий архив: 2006.12.31;
Скачать: CL | DM;

Наверх




Память: 0.47 MB
Время: 0.03 c
2-1165968733
ph0sgen
2006-12-13 03:12
2006.12.31
Загрузка DLL


2-1165934770
Ezorcist
2006-12-12 17:46
2006.12.31
как запихнуть картинку в файл ресурсов?


3-1161036521
БогданБ
2006-10-17 02:08
2006.12.31
Как указатель строки DBGridEh SQL запроса сопоставить с базой.


2-1166085841
iXT
2006-12-14 11:44
2006.12.31
RAM Drive


15-1165773689
$Pl@Sh
2006-12-10 21:01
2006.12.31
Откуда выражение?