0

I need to write a driver which is capable of reading and writing on the serial and the can bus port.

The serial port is realized with a sigaction() and an event handler. When I try to realize the same thing for the can bus, just the last event handler will be notified as there can be just on event handle assigned to the sigaction().

Is there any other possibility to solve this problem?

alk
  • 69,737
  • 10
  • 105
  • 255
unikat
  • 341
  • 2
  • 5
  • 14
  • 1
    You have to restrict all your function calls within your signal handler to async-signal-safe functions. Read the POSIX specification [here](http://pubs.opengroup.org/onlinepubs/009695399/functions/xsh_chap02_04.html) and the Linux man page [here](http://man7.org/linux/man-pages/man7/signal.7.html) Each page includes a list of async-signal-safe function calls that can safely be made from a signal handler. It's possible the Linux list differs from the POSIX standard list - I haven't compared the two closely. – Andrew Henle Feb 22 '16 at 10:11

1 Answers1

0

Your signal handler needs to determine why the signal was raised and act appropriately. You're probably going to want to block further signals with sigprocmask() as you could be interrupted in the signal handler, check if any data is available on both the serial port and the can bus, copy it out or set whatever flags you need to, then unblock signals at the end of your signal handler.

Sean Comeau
  • 115
  • 6