PDA

View Full Version : Problem with visualizing process data on BananaPI



gromar
25th May 2015, 13:02
Hello!

My visualization will show booking status of seats in the bus. You can see whole bus with seats which should change colours and also numbers of free/ busy seats below the main picture. For example: at first there are 42 free green seats so we can see text: "42 free"; "0 busy". Let's say 2 people will sit on two seats. Main pic will change: there will be 40 seats green and 2 red one. Same with the text below: "40 free" and "2 busy".

I managed to synchronize signals from module box (CAN bus line) to BananaPi using TI SN65HVD230D transceiver. I got information from each ID seat section per one frame (seats 1-32 , 33-64 and status of each seat - free, taken, error and not available). I attach receive.c file (http://svn.code.sf.net/p/can4linux/code/trunk/can4linux-examples/receive.c) which I'm using to check the frames (in Terminal typing ./receive -t3 -H).

First I thought about writing a timer which will collect the data from receive.c. each 1s - I wonder how exactly I should declare data to be seen in Qt in my QTimer.
After I done that I thought to visualize state of seats - I think I should use slots and signals of each seat depending of its state (for free seat - graphic with green seat, and for taken/busy one - a red graphic seat). Is this a good idea?

Thank you in advance for each tip :)

Example of frames:

0.167986 938/0x000003aa : bD ( 8 ): 00 fc ff ff ff ff ff 3f - noone is sitting
0.167963 938/0x000003aa : bD ( 8 ): 01 fc ff ff ff ff ff 3f - seat no 1 is taken/ busy
0.167972 938/0x000003aa : bD ( 8 ): 04 fc ff ff ff ff ff 3f - seat no 2 is taken/ busy
0.167973 938/0x000003aa : bD ( 8 ): 10 00 fc ff ff ff ff 3f - seat no 3 is taken/busy
0.167973 938/0x000003aa : bD ( 8 ): 40 00 fc ff ff ff ff 3f - seat no 4 is taken/busy
0.167981 938/0x000003aa : bD ( 8 ): 00 01 fc ff ff ff ff 3f - seat no 5 is taken/busy
0.168021 938/0x000003aa : bD ( 8 ): 00 04 fc ff ff ff ff 3f - seat no 6 is taken/busy
0.167986 938/0x000003aa : bD ( 8 ): 00 10 fc ff ff ff ff 3f - seat no 7 is taken/busy
0.167988 938/0x000003aa : bD ( 8 ): 00 40 fc ff ff ff ff 3f - seat no 8 is taken/busy
0.168017 938/0x000003aa : bD ( 8 ): 00 00 fd ff ff ff ff 3f - seat no 9 is taken/busy

0.168023 938/0x000003aa : bD ( 8 ): 00 00 fc ff ff ff ff 7f - seat no 32 is taken/busy
0.167001 939/0x000003ab : bD ( 8 ): ff ff ff ff ff fc ff ff - seat no 53 is free
0.167023 939/0x000003ab : bD ( 8 ): ff ff ff ff ff fd ff ff - seat no 53 is taken/busy

0.167992 938/0x000003aa : bD ( 8 ): 00 01 fc ff ff ff ff 7f - seat no 5 & 32 are taken/ busy
0.167986 938/0x000003aa : bD ( 8 ): 05 00 fc ff ff ff ff 3f - seat no 1 & 2 are taken/ busy
0.167965 938/0x000003aa : bD ( 8 ): 40 01 fc ff ff ff ff 3f - seat no 4 & 5 are taken/ busy

0.167971 938/0x000003aa : bD ( 8 ): 50 01 fc ff ff ff ff 3f - seat no 3, 4 and 5 are taken/busy

ChrisW67
26th May 2015, 22:00
If you are going to use the command line utility to receive data from the sensors then you should start it with QProcess and react when dataReady() Is signalled. Read the available data on to the end of a QByteArray buffer and then, for each full line in tHe buffer, parse the line, update your GUI, and remove the line from the buffer. In this approach the Qt program does not poll for data, it just waits to receive it.

If you are going to build the receiving code into your program then a different approach will be required.