Forum: PC-Programmierung DCB Einstellungen


von Thomas H. (datatom)


Lesenswert?

Hallo zusammen,

habe immer noch das Problem mit dem verzögerten Empfangen von Daten vom 
Controller zum PC. Ich möchte Handshake ausschalten. Kann mir jemand 
sagen, ob das mit diesen Einstellungen klappt:
1
// Initialize the DCBlength member. 
2
PortDCB.DCBlength = sizeof (DCB); 
3
4
// Get the default port setting information.
5
GetCommState (hPort, &PortDCB);
6
7
// Change the DCB structure settings.
8
PortDCB.BaudRate = 9600;              // Current baud 
9
PortDCB.fBinary = TRUE;               // Binary mode; no EOF check 
10
PortDCB.fParity = TRUE;               // Enable parity checking 
11
PortDCB.fOutxCtsFlow = FALSE;         // No CTS output flow control 
12
PortDCB.fOutxDsrFlow = FALSE;         // No DSR output flow control 
13
PortDCB.fDtrControl = DTR_CONTROL_ENABLE; 
14
                                      // DTR flow control type 
15
PortDCB.fDsrSensitivity = FALSE;      // DSR sensitivity 
16
PortDCB.fTXContinueOnXoff = TRUE;     // XOFF continues Tx 
17
PortDCB.fOutX = FALSE;                // No XON/XOFF out flow control 
18
PortDCB.fInX = FALSE;                 // No XON/XOFF in flow control 
19
PortDCB.fErrorChar = FALSE;           // Disable error replacement 
20
PortDCB.fNull = FALSE;                // Disable null stripping 
21
PortDCB.fRtsControl = RTS_CONTROL_ENABLE; 
22
                                      // RTS flow control 
23
PortDCB.fAbortOnError = FALSE;        // Do not abort reads/writes on 
24
                                      // error
25
PortDCB.ByteSize = 8;                 // Number of bits/byte, 4-8 
26
PortDCB.Parity = NOPARITY;            // 0-4=no,odd,even,mark,space 
27
PortDCB.StopBits = ONESTOPBIT;        // 0,1,2 = 1, 1.5, 2

Vielen Dank.

Grüße

datatom

von Rufus Τ. F. (rufus) Benutzerseite


Lesenswert?

Thomas Holländer schrieb:
> habe immer noch das Problem mit dem verzögerten Empfangen von Daten vom
> Controller zum PC.

Ist da ein Knoten im Satz?

Wo ist der Link auf den Thread, in dem Du dieses Problem schon 
geschildert hast?


Ansonsten sieht das hier merkwürdig aus:

> PortDCB.fParity = TRUE;               // Enable parity checking

> PortDCB.Parity = NOPARITY;            // 0-4=no,odd,even,mark,space


Wie initialisierst Du die Struktur vor dieser Zeile hier?

> PortDCB.DCBlength = sizeof (DCB);

von Thomas H. (datatom)


Lesenswert?

>
>
> Ansonsten sieht das hier merkwürdig aus:
>
>> PortDCB.fParity = TRUE;               // Enable parity checking
>
>> PortDCB.Parity = NOPARITY;            // 0-4=no,odd,even,mark,space


Habe ich von Microsoft:

http://msdn.microsoft.com/en-us/library/aa450503.aspx



>
>
> Wie initialisierst Du die Struktur vor dieser Zeile hier?
>
>> PortDCB.DCBlength = sizeof (DCB);


Gar nicht. Wie soll das denn gehen?

von Rufus Τ. F. (rufus) Benutzerseite


Lesenswert?

Thomas Holländer schrieb:
> Habe ich von Microsoft:

Da geht es um Windows CE.

Sieh Dir besser das hier an:

http://msdn.microsoft.com/en-us/library/windows/desktop/aa363201%28v=vs.85%29.aspx

Thomas Holländer schrieb:
>> Wie initialisierst Du die Struktur vor dieser Zeile hier?
>>
>>> PortDCB.DCBlength = sizeof (DCB);
>
>
> Gar nicht. Wie soll das denn gehen?

memset.

In obigem MS-Beispiel wird zwar SecureZeroMemory verwendet, das aber 
macht hier nichts relevant anderes.

Bitte melde dich an um einen Beitrag zu schreiben. Anmeldung ist kostenlos und dauert nur eine Minute.
Bestehender Account
Schon ein Account bei Google/GoogleMail? Keine Anmeldung erforderlich!
Mit Google-Account einloggen
Noch kein Account? Hier anmelden.