Seite 1 von 1

[gelöst]Qextserialport und lineStatus ()

Verfasst: 12. Dezember 2006 12:19
von dodgeripper
ich arbeite mit qt 3.3 und dem qtextserialport als serialklasse.
meine app lüppt auch ohne probs, nur möchte in nun zusätzlich den status vom port abfragen um gewisse aktions erst bei bestimmten portzuständen auszuführen.
dafür iss ja die linstatusabfrage da, aber wie damit gearbeitet wird kann ich aus der doku nicht rauslesen.

hier mal der auszug

unsigned long Posix_QextSerialPort::lineStatus ( void ) [virtual]

returns the line status as stored by the port function. This function will retrieve the states of the following lines: DCD, CTS, DSR, and RI. On POSIX systems, the following additional lines can be monitored: DTR, RTS, Secondary TXD, and Secondary RXD. The value returned is an unsigned long with specific bits indicating which lines are high. The following constants should be used to examine the states of individual lines:
Mask Line
------ ----
LS_CTS CTS
LS_DSR DSR
LS_DCD DCD
LS_RI RI
LS_RTS RTS (POSIX only)
LS_DTR DTR (POSIX only)
LS_ST Secondary TXD (POSIX only)
LS_SR Secondary RXD (POSIX only)

This function will return 0 if the port associated with the class is not currently open.

ich kann mit dem ergebniss des unsigned long nichts werden, bzw verstehe die ausgabe nicht.
was ich verstanden hab, das ich 0 bei nicht geöffneten port habe.

Verfasst: 13. Dezember 2006 19:53
von dodgeripper
ok habs hinbekommen, manchmal hilft ja nachdenken :D

unsigned long ls;
ls = serialPort->lineStatus();
if (( ls &LS_DTR ) == 0 )
{
QMessageBox::critical( this, "DTR_Test", "DTR= NotSet" );
}
else
{
QMessageBox::critical( this, "DTR_Test", "DTR= Set" );
}