Commit c8a37283cdb1627a38d1c36626c693aea79d05e6

Authored by Enrique Díaz Roque
1 parent 81ecedd2
Exists in master and in 1 other branch dev

Updated inoChannel, commands should be issued now and new frames should be accep…

…ted (but no processed!)
Showing 1 changed file with 20 additions and 12 deletions   Show diff stats
app/src/inoChannel.cpp
... ... @@ -6,7 +6,7 @@ void inoChannel::setup(string device) {
6 6 }
7 7  
8 8 void inoChannel::exit() {
9   - // there is no memory to free (now)
  9 + // there is no memory to free (now)
10 10 }
11 11  
12 12 void inoChannel::identify() {
... ... @@ -15,21 +15,18 @@ void inoChannel::identify() {
15 15 cmd.append(device);
16 16 cmd.push_back(HW_HELO);
17 17 cmd.push_back(device.size());
18   -
19 18 commands.push(command);
20 19 }
21 20  
22 21 void inoChannel::startStream() {
23 22 string cmd;
24 23 cmd.push_back(HW_START_STREAM);
25   -
26 24 commands.push(cmd);
27 25 }
28 26  
29 27 void inoChannel::stopStream() {
30 28 string cmd;
31 29 cmd.push_back(HW_STOP_STREAM);
32   -
33 30 commands.push(cmd);
34 31 }
35 32  
... ... @@ -55,14 +52,25 @@ void inoChannel::threadedFunction() {
55 52 serial.flush();
56 53 checkSystem();
57 54 while(isThreadRunning()) {
58   - // Read from Arduino (frame)
59   - // Check commands / Send
60   -
61   - if (commands.size() > 1) {
62   - string cmd = commands.front();
63   - if (serial.writeBytes(cmd.c_str(), cmd.size())) {
64   - commands.pop();
65   - }
  55 + while(serial.available() < 1);
  56 + switch(serial.read()) {
  57 + case HW_NEW_FRAME:
  58 + {
  59 + while(serial.avilable() < 256);
  60 +
  61 + // serial.readBytes(buffer, 256);
  62 +
  63 + break;
  64 + }
  65 + default:
  66 + // no idea what could go wrong
  67 + break;
  68 + }
  69 + if(commands.size() > 1) {
  70 + string cmd = commands.front();
  71 + if(serial.writeBytes(cmd.c_str(), cmd.size())) {
  72 + commands.pop();
  73 + }
66 74 }
67 75 }
68 76 string status("Closed");
... ...