31
µTasker general / Also about the uart get data!
« on: September 08, 2007, 10:40:45 AM »
When I send the data to the uart.data=(0x11,0x22,0x33,0x44,0x55)
like this:
#else
if ((iAppState & (STATE_ACTIVE | STATE_DELAYING | STATE_ESCAPING | STATE_RESTARTING | STATE_VALIDATING)) && (Length = fnMsgs(SerialPortID))) {
while ((Length = fnRead( SerialPortID, ucInputMessage, MEDIUM_MESSAGE)) != 0) {
fnEchoInput(ucInputMessage, Length);
fnDebugMsg("\n\rLED ON OFF\n\r");
if (usData_state == ES_NO_CONNECTION) {
if (fnCommandInput(ucInputMessage, Length, SOURCE_SERIAL)) {
if (fnInitiateLogin(ES_SERIAL_LOGIN) == TELNET_ON_LINE) {
static const CHAR ucCOMMAND_MODE_BLOCKED[] = "Command line blocked\r\n";
fnWrite(SerialPortID, (unsigned char *)ucCOMMAND_MODE_BLOCKED, sizeof(ucCOMMAND_MODE_BLOCKED));
}
}
}
I find the Length always 1,and printf the "LED ON OFF" five times! Why!
I want the get the data(0x11,0x22,0x33,0x44,0x55) is a long buff,not the CHAR_MODE one by one!
I want the Length is 5 not 1,so that I can easy to use the buff.not like the char!
When I #define TEST_MSG_MODE,but it never go to the
#ifdef TEST_MSG_MODE
#ifdef TEST_MSG_CNT_MODE
while (fnMsgs(SerialPortID)) {
unsigned char ucLength;
fnRead( SerialPortID, &ucLength, 1); // get message length
Length = fnRead( SerialPortID, ucInputMessage, ucLength);
fnDebugMsg("\n\rLED ON 1OFF\n\r");
fnEchoInput(ucInputMessage, ucLength);
}
#else
while (fnMsgs(SerialPortID)) {
Length = fnRead( SerialPortID, ucInputMessage, MEDIUM_MESSAGE);
fnDebugMsg("\n\rLED2 ON OFF\n\r");
fnEchoInput(ucInputMessage, Length);
}
#endif
fnMsgs(SerialPortID); This is called to return the number of waiting messages. In character mode this is equal to the number of characters but in message mode it will indicate the number of complete messages and not individual characters.
how can I get the "in message mode",I want to get complete messages and not individual characters!
like this:
#else
if ((iAppState & (STATE_ACTIVE | STATE_DELAYING | STATE_ESCAPING | STATE_RESTARTING | STATE_VALIDATING)) && (Length = fnMsgs(SerialPortID))) {
while ((Length = fnRead( SerialPortID, ucInputMessage, MEDIUM_MESSAGE)) != 0) {
fnEchoInput(ucInputMessage, Length);
fnDebugMsg("\n\rLED ON OFF\n\r");
if (usData_state == ES_NO_CONNECTION) {
if (fnCommandInput(ucInputMessage, Length, SOURCE_SERIAL)) {
if (fnInitiateLogin(ES_SERIAL_LOGIN) == TELNET_ON_LINE) {
static const CHAR ucCOMMAND_MODE_BLOCKED[] = "Command line blocked\r\n";
fnWrite(SerialPortID, (unsigned char *)ucCOMMAND_MODE_BLOCKED, sizeof(ucCOMMAND_MODE_BLOCKED));
}
}
}
I find the Length always 1,and printf the "LED ON OFF" five times! Why!
I want the get the data(0x11,0x22,0x33,0x44,0x55) is a long buff,not the CHAR_MODE one by one!
I want the Length is 5 not 1,so that I can easy to use the buff.not like the char!
When I #define TEST_MSG_MODE,but it never go to the
#ifdef TEST_MSG_MODE
#ifdef TEST_MSG_CNT_MODE
while (fnMsgs(SerialPortID)) {
unsigned char ucLength;
fnRead( SerialPortID, &ucLength, 1); // get message length
Length = fnRead( SerialPortID, ucInputMessage, ucLength);
fnDebugMsg("\n\rLED ON 1OFF\n\r");
fnEchoInput(ucInputMessage, ucLength);
}
#else
while (fnMsgs(SerialPortID)) {
Length = fnRead( SerialPortID, ucInputMessage, MEDIUM_MESSAGE);
fnDebugMsg("\n\rLED2 ON OFF\n\r");
fnEchoInput(ucInputMessage, Length);
}
#endif
fnMsgs(SerialPortID); This is called to return the number of waiting messages. In character mode this is equal to the number of characters but in message mode it will indicate the number of complete messages and not individual characters.
how can I get the "in message mode",I want to get complete messages and not individual characters!