Hi all,
I use a thread to read on the uart when they have interrupt on serial 1 RX. I use a connectcore 9C with NET +OS 7.4.2 The problem is that the interrupt is always on and the serial cable is not plug… You can see my code. Any one have idea?
void * stackUART;
stackUART = malloc (8192);
if (stackUART == NULL) {
printf (“Unable to allocate UART Control thread stack.”);
return -1;
}
result = tx_thread_create (&_uartThread, “UART Thread”, decodeUART, 0, stackUART, 8192, 10, 10, 1, TX_DONT_START);
if (result != TX_SUCCESS) {
printf (“Unable to allocate UART thread stack.”);
return -1;
}
// Open serial port A for Modbus communication.
_modbusPort = open (“/com/0”, O_RDWR | O_NONBLOCK);
if (_modbusPort <=0) {
printf (“Unable to open modbusPort”);
return -1;
}
// get the current serial attributes
if (tcgetattr(_modbusPort, &SerialModbusPortSettings) < 0)
{
printf("tcgetattr modbus failed
");
return -1;
}
// set the baudrate modbus
cfsetospeed(&SerialModbusPortSettings, MODBUS_BAUDRATE);
if (tcsetattr(_modbusPort, TCSANOW, &SerialModbusPortSettings) < 0)
{
printf("tcsetattr modbus failed
");
return -1;
}
naIsrInstall(SER1RX_INTERRUPT,(NA_ISR_HANDLER)uartISR, NULL);
void uartISR(void * param)
{
_uartReceved = true;
tx_thread_resume(&_uartThread);
return;
}
void decodeUART(ULONG inValue)
{
int result;
char buff[10];
while(1)
{
if(_uartReceved)
{
result = naInterruptDisable(SER1RX_INTERRUPT);
read(_modbusPort,buff,sizeof buff);
_uartReceved = false;
result = naInterruptEnable(SER1RX_INTERRUPT);
}
tx_thread_suspend(tx_thread_identify());
}
}
thanks for the reply.