Board index FlightGear Support Interfacing

[SOLVED] debug serial connection Arduino uno  Topic is solved

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

[SOLVED] debug serial connection Arduino uno  

Postby rooman » Sun Sep 04, 2022 4:55 pm

Hi there, I'm new to Arduino but trying hard.
I've wired up the Uno and copied all code according to the example n°2 here https://wiki.flightgear.org/Howto:Use_Arduino_with_FlightGear
The serial monitor shows correct readings in the IDE so all is ok, but FG does not seem to react.
The xml file is in
/usr/share/games/flightgear/Protocol

How can I debug this problem?
Last edited by rooman on Sun Sep 04, 2022 8:03 pm, edited 1 time in total.
Grew up with Dr Who then discovered Monty Python and Middle Earth. The world was never the same.
rooman
 
Posts: 197
Joined: Sun Apr 12, 2015 7:26 pm
Location: Lausanne, Switzerland
Callsign: HB-ROO
Version: Next + LTS
OS: Ubuntu latest stable

Re: debug serial connection Arduino uno

Postby ludomotico » Sun Sep 04, 2022 5:43 pm

Hello rooman

The I/O interface in FlightGear is not the most error resistant nor debuggable. Lots of things can go wrong, and no messages will be shown anywhere. Check:

- All cable connections are working OK in the Arduino.
- There could be an error in the XML file. Please, check the FG console for errors.
- The I/O interface is only started when FG begins: plug in the Arduino and then run FlightGear. You cannot plug the Arduino while FG is running. You must restart FG if you change anything in the Arduino.
- The wiki page lists /dev/ttyACM0 as the device of the Arduino, but it might be different in your system. Double check this is the device assigned in your system to the Arduino. I would say that /dev/ttyS0 or /dev/ttyUSB0 (or other numbers) are more common device names.
- If you are using Windows, keep in mind you cannot use the Arduino serial monitor and FlightGear at the same time! It is much harder to debug without the serial monitor, I know.
- Check if the properties are really changed in FG: Debug->see properties. Recent versions of the C172 in FG have two engines (one as default, another for the alternative versions), and maybe you are not using the right property name to control throttle or strobe. If this is the case, change your XML with the real property names.
User avatar
ludomotico
 
Posts: 1269
Joined: Tue Apr 24, 2012 2:01 pm
Version: nightly
OS: Windows 10

Re: debug serial connection Arduino uno

Postby polly » Sun Sep 04, 2022 6:06 pm

Edit lodomotico covered most of this but it's worthwhile to scan to flightgear log to verify things happened OK:

In you flightgear log: ~/.fgfs/fgfs.log search on 'generic' to see that the command to load a protocol is enacted.
Search on the name of you protocol file, 'hardware' in the log to check the file is interpreted OK


( already covered ! )

Just check, if the Arduino IDE is showing words from the Arduino, that the Aduino Tools-Port menu item confirms the connection is on ttyACM0, some of my Arduino-like report as ACMx, others as ttyUSBx, you may need to change the command you use for flightgear:

Code: Select all
--generic=serial,in,30,/dev/ttyACM0,9600,controltest

Code: Select all
--generic=serial,in,30,/dev/ttyUSB0,9600,controltest

( I've never had a problem with a higher baud rate, 115200 )

Use the web http server inside flightgear to view the properties tree for the properties you intend to change, in the example you quoted:
Code: Select all
/controls/flight/elevator

ought to be seen to change. You could temporarily use a different property name such as /sytem/test/acm/value1
in the protocol file to confirm the properties change, in case the joystick is interfereing with the flight controls.
User avatar
polly
 
Posts: 969
Joined: Thu Nov 04, 2010 3:45 pm

Re: debug serial connection Arduino uno

Postby rooman » Sun Sep 04, 2022 8:03 pm

thanks for following this issue.
OS Ubuntu 21.10
In log file I find
5.78 [INFO]:general ./src/Main/options.cxx:688: Channel string = serial,in,30,/dev/ttyACM0,9600,controltest
5.78 [INFO]:general ./src/Main/options.cxx:2608: option:generic = serial,in,30,/dev/ttyACM0,9600,controltest
for me FG is picking up the controltest.xml ok.
The IDE shows /dev/ttyACM0.
The example 2 which I'm trying tries to manipulate the throttle and the strobe.
This latter seems to be <node>/controls/lighting/strobe</node>.
I've just found an error in the log file, I had saved the xml file with a text editor as word 2003 xml format! =document full of s**t.

Got the strobe working Hoorah!

I'm learning to double check everything, I'm really sorry to have bothered you, thanks for the support.
Grew up with Dr Who then discovered Monty Python and Middle Earth. The world was never the same.
rooman
 
Posts: 197
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 6 guests