joan2937 / pigpio

pigpio is a C library for the Raspberry which allows control of the General Purpose Input Outputs (GPIO).
The Unlicense
1.45k stars 406 forks source link

How to best use Threads?? #237

Closed jdalicandro closed 4 years ago

jdalicandro commented 6 years ago

First - thank you for all you've done - - it's been quite straightforward to bring my Raspberry pi v3 B+ up and connect simultaneously to the multitude of sensors.

Here's my question:

Additionally, I'd like to have my RPI respond to commands sent through SSH.

Problem is cannot simply wait on getchar(), as this blocks everything else.

Originally, I was going to create a thread to wait on the getchar(); but this doesn't seem to align with how you created threads (on the GPIOs).

So, now I'm thinking that the operation of the sensors can be made into threads.

Which would be the best way to simultaneously operate sensors while "waiting on an SSH command" ?

Thank you for answering my question...

guymcswain commented 4 years ago

It sounds like you are controlling sensors through pigpio using a C program and then you want the ability to remotely access the sensors as well. If that assumption is correct, you can achieve this by using the socket interface and the pigpiod daemon. Write you C program using the pigpiod C I/F. Now you can access the same sensors remotely from your choice of C program or higher level script languages Python or Javascript.