tx_timer + Write() serial problem

Hi!

I have a big problem with a tx_timer and a serial write function.

I created a timer with:
tx_timer_create (&Timer, “Com Timer”, Comm, 0, 1000, 100, TX_AUTO_ACTIVATE);

And in the Comm funtion I use a write command for the serial port:
result = write (zeroFd, sendBuffer, bytestosend);

But when the timer tries to write to the serial line I get an exception…

When I call the function from another function it works fine, so it’s just when I call the write() command from a timer…

Have anyone tried this, and maybe have a workaround or a solution

Specs:
NETOS 7.1.1
Digi Connect ME 4mb -C JTAG

Thx
/Jakob

The timer executes in interrupt context, so you need to make sure your writes are non-blocking to the serial port. Blocking in interrupt context will cause crashes.

I should also mention that it may also be able to cause a crash if you have two or more threads trying to access the serial port and at least one of them a timer thread. I.E. the serial ports are mutex protected and thus if thread b had the serial port locked while thread a (timer thread) executed, it would also cause a blocking condition.