Yes, I am working with the SAM7X
Mapped COM3 on PC to SERIAL_PORT_0.
Running the simulation with the GPS sentences coming in on the COM port:
while ((length = fnMsgs(SerialPortID)) != 0)
SerialPortID= 19
length=52428-----> and the buffer contains garbage.
My code below.
The task is running at 1 second rate.
#include "config.h"
#define OWN_TASK TASK_MY_FIRST_TASK
//Prototypes
void setUart(unsigned char mode);
// Global variables
static QUEUE_HANDLE SerialPortID; // quehandler for serialport 2
extern void fnMyFirstTask(TTASKTABLE *ptrTaskTable)
{
QUEUE_TRANSFER length;
unsigned char ucInputBuffer[100];
static int iState = 0;
static unsigned char ucCounter = 0;
static const char LCDdsp[] = " From Lav's task"; // display message from present cursor position
if (iState== 0)
{
setUart(FOR_READ ); //Rx only
iState = 1;
}
while ((length = fnMsgs(SerialPortID)) != 0) { // get number of waiting bytes
if (length > sizeof(ucInputBuffer)) { // ensure buffer can’t be overrun
length = sizeof(ucInputBuffer);
}
fnRead(SerialPortID, ucInputBuffer, length); // read to a local buffer
}
// fnDebugMsg("Hello, World! Test number ");
/* fnDebugDec(ucCounter++, sizeof(ucCounter));
fnDebugMsg("\r\n");*/
TOGGLE_LAV_OUT() ;
fnDoLCD_com_text(E_LCD_TEXT, (unsigned char *)LCDdsp, (sizeof(LCDdsp) - 1));
//uTaskerStateChange(OWN_TASK, UTASKER_GO); // switch to polling mode of operation
}
void setUart(unsigned char mode)
{
TTYTABLE tInterfaceParameters; //table for passing information to driver
tInterfaceParameters.Channel = SERIAL_PORT_0; // serial 0, 1, 2, 3, 4, etc.
tInterfaceParameters.ucSpeed = SERIAL_BAUD_4800; // 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 = TASK_MY_FIRST_TASK;
tInterfaceParameters.Config = (CHAR_8 | NO_PARITY | ONE_STOP | NO_HANDSHAKE | CHAR_MODE );
if ( (SerialPortID = fnOpen(TYPE_TTY, mode, &tInterfaceParameters)) != 0 ) // open or change the channel with defined configurations (initially inactive)
fnDriver( SerialPortID, (RX_ON | TX_ON), 0 ); // enable RX & TX
}