µTasker Forum
µTasker Forum => NXPTM M522XX, KINETIS and i.MX RT => Topic started by: kyork on August 29, 2008, 10:23:43 PM
-
This may be a simple misunderstanding on my part. When operating in XON/XOFF mode, should the driver pass those control bytes to the application when fnRead() is called?
TTYTABLE tInterfaceParameters; //table for passing information to driver
QUEUE_HANDLE serialPortId;
tInterfaceParameters.Channel = 1; // serial 0, 1, 2, 3, 4, etc.
tInterfaceParameters.ucSpeed = SERIAL_BAUD_57600; // baud rate
tInterfaceParameters.Rx_tx_sizes.RxQueueSize = RX_BUFFER_SIZE; // input buffer size
tInterfaceParameters.Rx_tx_sizes.TxQueueSize = TX_BUFFER_SIZE; // outpu buffer size
tInterfaceParameters.Task_to_wake = 0;
tInterfaceParameters.usConfig = (CHAR_8 | NO_PARITY | USE_XON_OFF | ONE_STOP | NO_HANDSHAKE | CHAR_MODE);
serialPortId = fnOpen(TYPE_TTY, FOR_I_O, &tInterfaceParameters);
if ( serialPortId != 0 ) // open or change the channel with defined configurations (initially inactive)
{
fnDriver( serialPortId, (RX_ON | TX_ON), 0 ); // enable RX & TX
}
And then later
int count = fnRead(serialPortId, inBuffer, inBlockLen);
inBuffer will contain a 0x11, the XON byte. Should this be the case? Shouldn't the driver remove those control bytes?
-
I don't know if the behavior is correct, but I changed:
else if ((XON_CODE == ch) && (tx_ctl->ucState & TX_WAIT)) {
tx_ctl->ucState &= ~TX_WAIT; // unblock transmitter
send_next_byte(Channel, tx_ctl); // restart transmission, if paused
return;
}
to
else if(XON_CODE == ch) {
if (tx_ctl->ucState & TX_WAIT) {
tx_ctl->ucState &= ~TX_WAIT; // unblock transmitter
send_next_byte(Channel, tx_ctl); // restart transmission, if paused
}
return;
}
in fnSciRxByte() in Tty_drv.c and it fixed my issue.
-
Hi
I believe your understand is correct. When the sequence XOFF, XON, XOFF, XON occurs it works correctly. If, however, XON is received when not expected (no XOFF before) I think that it is not correct to pass the character to the input buffer.
It seems sensible to improve this:
else if (XON_CODE == ch) { // {13}
if (tx_ctl->ucState & TX_WAIT) { // if in XOFF state
tx_ctl->ucState &= ~TX_WAIT; // unblock transmitter
send_next_byte(Channel, tx_ctl); // restart transmission
}
return;
}
This is slightly different from your fix since it doesn't call send_next_byte() if it was not in XOFF state. Probably calling this will not cause any real problem but this takes no risks.
Thanks!
Regards
Mark