Visualization of data process on BananaPI (in C/ C++)

89 views Asked by At

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 and QProcess. Could someone provide a example code how it should work?

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

First of all I'd like to see outputs signals (frames) in Qty. When I push the button after debugging I only see in Application Output:

  1. " "
  2. Gotowe!
  3. 0

and so on after pushing the button each time.

My code: mywindow.cpp

#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <QProcess>
#include <QDebug>
#include <QByteArray>

MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
 ui(new Ui::MainWindow)
 {
 ui->setupUi(this);
 }

MainWindow::~MainWindow()
{
 delete ui;
}

void MainWindow::on_pushButton_clicked()
{
QProcess process(this);
QByteArray byteArray = process.readAllStandardOutput();
process.setProcessChannelMode(QProcess::MergedChannels);
process.start("test.sh");
process.waitForReadyRead();
qDebug() << process.readAll();
qDebug("Gotowe!");
process.waitForBytesWritten();
process.waitForFinished();
qDebug() << process.exitCode();

test.sh is simple bash script to load ./receive with commands "-t3 -H)

#!/bin/bash
./receive -t3 -H
0

There are 0 answers