Note that there are some explanatory texts on larger screens.

plurals
  1. POsignal callback and pthread sync
    primarykey
    data
    text
    <p>On my app I have a pthread running a while(1) that read a socket client and a serial callback function. My app receive messages from a serial (like /dev/ttyS0) and receive messages from socket. The problem: the app crash after receive some messages from serial, on this moment the socket is receiving nothing. But if I comment the thread creation the app work fine.</p> <p>code draft:</p> <pre><code>// Socket Thread static void *Socket(void *arg) { // socket inicialization while (1) { ret = read(client, buffer, sizeof(buffer)-1); // do something } } // serial callback static void SerialCallback(int id, unsigned char *buffer, int length) { // do something } // main int main (void) { // start and configure serial callback cssl_start(); Serial = cssl_open(SERIAL_PORT, SerialCallback, 0, 115200, 8, 0, 1); // create the pthread // If I comment the line below the app work fine pthread_create(&amp;Thread_Socket, NULL, Socket, NULL); while (1) { } } </code></pre> <p>Notes:</p> <ul> <li><p>I use the library cssl (http://sourceforge.net/projects/cssl/) to deal with serial. This library use a real time signal.</p></li> <li><p>For tests purposes I use socat to generate pseudo-terminals (like /dev/pts/XX)</p></li> <li><p>The serial callback is called each time that serial receive one or more bytes</p></li> <li><p>I am using the cutecom to send messages to serial</p></li> </ul> <hr> <p>Added new tests information in 2012.07.16</p> <p>First test: I replace the line of read function by a while(1); and the problem follow (so, the problem is not related with read function).</p> <p>Second test: Using the full code (above example), I use two external usb/serial converter loopback connected, work rightly.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload