Board index FlightGear Support Interfacing

serial data order = generic output chunk order?  Topic is solved

Connecting two computers, using generic protocol, connecting with Matlab?

serial data order = generic output chunk order?  

Postby rooman » Mon Sep 12, 2022 2:19 pm

In my FG generic output xml file there are 4 different data to be sent.
The var separator is set as "," and line separator as "\n"
I'll be outputting 3 boolean properties ON/OFF, UP/DOWN etc and 1 long (flaps)

Question
Arduino will it pick up the data packet as a complete line each time with the data in the same order as the chunks in the xml file ? So I can parse for "," to do stuff?
Using serial.read() etc.
Grew up with Dr Who then discovered Monty Python and Middle Earth. The world was never the same.
rooman
 
Posts: 169
Joined: Sun Apr 12, 2015 7:26 pm
Location: Lausanne, Switzerland
Callsign: HB-ROO
Version: Next + LTS
OS: Ubuntu latest stable

Re: serial data order = generic output chunk order?

Postby polly » Mon Sep 12, 2022 2:48 pm

I think you have a choice:

Code: Select all
  while (Serial.available() > 0) {
    char inChar = Serial.read();
    if (client.connected()) {
      switch (inChar) {

or:

Code: Select all
  // test for when chars arriving on serial port, set ATTN
  //if ( Serial.available() && Serial.find('\n')  ) {
  if ( Serial.available() ) {
    // no wait for entire message  .. 115200bps 14 char ~ 1mSec there's a newline
    // delay(100);
    // read from buffer until first linefeed, remaining chars staay in hdwre serial buffer
    userCmdl = Serial.readStringUntil('\n');


That latter bit looks like I had a couple of stabs at it but, it receives whole lines
while the first does 'single shot' keyboard responses.
User avatar
polly
 
Posts: 956
Joined: Thu Nov 04, 2010 3:45 pm

Re: serial data order = generic output chunk order?

Postby rooman » Mon Sep 12, 2022 3:59 pm

I'll try something like that, tks.
Grew up with Dr Who then discovered Monty Python and Middle Earth. The world was never the same.
rooman
 
Posts: 169
Joined: Sun Apr 12, 2015 7:26 pm
Location: Lausanne, Switzerland
Callsign: HB-ROO
Version: Next + LTS
OS: Ubuntu latest stable


Return to Interfacing

Who is online

Users browsing this forum: No registered users and 3 guests