SI message port: WIKI error?

Help creating logic scripts for Air Manager Instruments

Moderators: Ralph, russ

Message
Author
User avatar
jph
Posts: 650
Joined: Fri Apr 10, 2020 12:50 pm
Location: Portugal

Re: SI message port: WIKI error?

#21 Post by jph » Wed Apr 21, 2021 5:32 am

Hi Tony,
I fully understand what you are saying and you are absolutely correct. There is enough information there to cover the operation. I really DO appreciate the input and feedback from all.

It is so easy for me, normally' to use a serial print / serial monitor debug from the IDE when learning anything new such as the 'struc' within the context of Arduino. Obviously this is not easily done here without passing all the Arduino information that I want to look at back to the AM console. I would find it MUCH easier to have debug at each end due to the difference in syntax between Arduino and LUA. I am just so used to having the debug console available within arduino when working on something new. Old age and habit...
Anyway :D I had a brainwave last night (dangerous I know.... :? :shock: :lol: ) and thought - heck - why not just use an Arduino DUE !. It has 2 usb serial ports on board and in theory I can use one for Messageport and the other as a debug monitor for the arduino code - and of course, For LUA I have the console within AM.
This probably sounds, at first glance, more complex than piping it all back though the AM console but I have few DUE Arduinos sat on the bench and it it would seem to offer the best of both worlds - at first for the viewing of the breakdown of the structure that I want to understand in a more hands on way, and play around with various options for breaking down and using the data 'struct' data within the Arduino IDE. so.............. The big thing then is that It will also massively help in the development of the more complex actual full arduino code for the Arduino end hardware / final project for whatever use it will be put to. I can develop on the DUE with the serial monitor from the second port and then use a 2560 for the final project if the DUE is overkill as to all intents and purposes the DUE can be used as a pseudo MEGA 2560 and has the same footprint / pin compatibility.
Anyway. I will experiment over the next day or so and then hopefully contribute something back to the community.
I will also try to offer feedback on using the Arduino DUE as a debug method for Message Port based hardware Arduino code in general.
Huge thanks again to Jackz Corjan and your good self.
Joe
“Everything in moderation, including moderation.”
“Experience is merely the name men gave to their mistakes.”
Joe (CISSP) -IT security consultant

User avatar
Sling
Posts: 4431
Joined: Mon Sep 11, 2017 2:37 pm
Contact:

Re: SI message port: WIKI error?

#22 Post by Sling » Wed Apr 21, 2021 8:18 am

I had a similar thought when I first used message port. It would be a good idea to use the extra serial ports on hardware that have them such as the MEGA2560. It’s not that much extra code on the Arduino to pump out whatever you want on one of those ports.

JackZ
Posts: 1850
Joined: Mon Feb 22, 2016 1:02 pm

Re: SI message port: WIKI error?

#23 Post by JackZ » Wed Apr 21, 2021 8:37 am

@Sling Interesting.
You mean the MEGA 2560 is able to operate two serial port simultaneously through USB? Wonder how to operate this feat.

@jph Simply using debug messages back from the Arduino side to AM Console as a feedback should be easier, no?

Jacques
My YouTube Chanel on the A320 (Real SOPs by an Airline Pilot IRL):
https://www.youtube.com/playlist?list=P ... 0Q6SBASRqJ

User avatar
Sling
Posts: 4431
Joined: Mon Sep 11, 2017 2:37 pm
Contact:

Re: SI message port: WIKI error?

#24 Post by Sling » Wed Apr 21, 2021 8:48 am

Not through USB but connected to a COM port. Most new laptops don’t have com ports these days but a cheap USB to COM adapter will do the trick if required.

User avatar
jph
Posts: 650
Joined: Fri Apr 10, 2020 12:50 pm
Location: Portugal

Re: SI message port: WIKI error?

#25 Post by jph » Wed Apr 21, 2021 9:51 am

@JackZ @Sling
Hi guys,
Definitely. I think this is the way to go. Firing all debug data from the Arduino code back to AM would be a nightmare imho - practically and for readability and actual use. Possible of course... , but.. also, if there is a failure to communicate with AM then there is no debug at all from Arduino !! - Major problem !. And of course this could well happen, and indeed, WILL happen. Passing every aspect of a debug of not just the message port but also individual libraries and coding in Arduino back to AM is simply not viable imho.

Jacques, Yes, the Mega, for example, has multiple UARTS / USARTS . (Hardware serial ports) as listed here .
https://www.arduino.cc/reference/en/lan ... on/serial/
As Tony says, they do not natively connect to the PC USB port. They need a simple Serial to USB converter such as the ubiquitous FTDI - as in -
https://www.aliexpress.com/item/3265014 ... 4c4ddlzdHL
I have half a dozen SOMEWHERE ! - but after digging through boxes this morning I cannot find them, so quickly ordered the above (4 units) from AliExpress with AliExpress shipping for faster delivery. (hint, if you use aliexpress - always use a good tracked shipping !)

For the mega, for example, you simply connect the USB Serial adapter (or if you like you can think of it as a Serial USB adapter ) to any hardware USART (serial port pins) on the arduino. (not the serial 0 port as this is used as the main serial / usb link) - This then plugs into a USB port on the PC and you simply see it as a standard serial port - job done ! :) . You can then use this for the 'terminal' in the Arduino IDE (or any other terminal program) but hey - just use the IDE Terminal.
In arduino code, for the MEGA 2560, then pins 19(RX), 18(TX) are 'serial 1' as can be seen in the link.

Simply connect those pins to the FTDI or similar adapter linked above - you only use 3 pins ! on the adapter you connect GND to GND on the Arduino, and then rx to tx and tx to rx. The rest of the pins are not needed and can be ignored.. Just ensure the jumper on the USB Serial board is set for for 5v or 3.3v depending on you device. For the mega it is 5V.

Then plug the output of the converter USB usb port - via a suitable USB cable (For example a Mini USB male to USB A male) - to the USB port on your PC and you will then see another com port appear ! - (deep joy ;) :mrgreen: ) then you are ready to go.
In your Arduino code you can then open a serial port to serial1 and use a directed port version of the normal serial.print via that as normal to the debug terminal
Such as, if you link the hardware serial 1 port of the mega - as per pins 19(RX), 18(TX) - then in the code, you would simply use
Serial1.begin(9600); // (or whatever Baud rate) - NOTE the Serial1 not Serial.
instead of
Serial.begin(9600);

and then all you Serial.xxxxx commands would be Serial1.xxxxx commands.
That is about it really.

The only slight issue (a non issue really) is that you use two pins fo the mega - but hey - no worries.
So all you need is the Mega and the FTDI or similar USB/serial (dirt cheap) and no hassle at all to set up. plug and pray. - unless you need the drivers for the chip, but in win 8 to 10 they are almost always native.

The Arduino DUE that I mentioned before has two 'serial' to USB ports on board - BUT !!!!!- may not be the best choice. I would go with the MEGA and a simple FTDI adapter as linked to above for the second serial USB.

The reason is that the DUE second port (non programming port) is actually native USB and although it CAN use standard serial - it is not the best (you can use the 'USBSERIAL' object) BUT !!!! the port is aimed at CDC comms and will cause you sleepless nights :shock:
It is great for running a HID device - AND message port etc, but not as two standard serial ports. (this is ONLY the DUE!)

The answer is to use the mega with an FTDI - or similar (there are various units and all cheap) with one of the hardware serial ports built into the MEGA.
I am definitely going this route as the nightmare of a complex message port linked Arduino code using multiple Arduino libraries and hardware devices etc - and being unable to debug the Arduino code without this is simply not something I would be prepared to undertake - with the debug terminal on a second serial port on the MEGA, then great !

The link I posted shows the devices with the extra USARTS (Hardware serial ports) .. as in, the UNO doesn't doesn't have any spare ones - .. but heck, most use the MEGA 2560 as the workhorse anyway and that is no issue as it has 3 'spare' ones.

Joe
“Everything in moderation, including moderation.”
“Experience is merely the name men gave to their mistakes.”
Joe (CISSP) -IT security consultant

Post Reply

Who is online

Users browsing this forum: No registered users and 9 guests