Wednesday, December 23, 2015

Raspberry Pi

I've been playing with Raspberry Pi for a while, it's quite fun. Once we know how to program it well, then things are much more easier. For me, I use C as my language, it supports C++ but it needs c++ library to be installed, C is enough powerful for my application. So, here's what I have done so far:

  1. I/O, I use BCM2835 library ( for the GPIO and SPI. This library is quite straightforward, easy to use, and understand. About this library, only the pinout assignment a little bit tricky, it seems that the pinouts for Raspberry Pi v2 is not usable, I have to use RPI_BPLUS_GPIO_J8_XX for pins more than 26, when I tried to use RPI_V2_GPIO_P1_XX I got a compilation error showing that it is not defined. When using this library, make sure to add "-lbcm2835" for compiling your program.
  2. Threads. In most of my program, I always use threads for doing the task because I don't want to have one task blocking the other tasks. If the tasks can be performed separately, then it must be run under threads. Critical sections must be used for making all the threads safe. For thread, I use pthread library. Make sure to add "-lpthread" for compiling your program.
  3. Sockets. For socket, I use standard unix socket programming, socket transfer is run in a thread with a state machine for controlling the connection state. This is quite straightforward. 
Unfortunately, at the moment I don't have any simple application that I could share here. If you have any difficulties just feel free to ask, I might be able to give you a clue. 

Happy Coding!:)

Labels: ,


Post a Comment

<< Home