Hobbyist Toolkit

cancel
Showing results for 
Search instead for 
Did you mean: 

LINX communication over serial1 instead of serial

Hello,

I'am trying to use LINX on on board that has several hardware serial

By default, the LINX firmware communicate over the main serial. For some reason I would like to set the communication over serial1.

Is this feasible? If yes, can you please let me know what should be changed in the firmware? I tried to look into the code but did not find clear evidence..

NB : i'am talking about the communication between PC and board. Not set an UART peripheral over serial1...

I hope I 'am clear, thanks in advance for your help !

0 Kudos
Message 1 of 12
(3,039 Views)

Hello again, 

I still have the problem, so after a few weeks I would like to raise this question again...

If not clear I can give more informations.

Many thanks in advance !

antoine

0 Kudos
Message 2 of 12
(2,827 Views)

You did not receive an answer since you are not detailed enough what you try to do.

 

What hardware do you want to use Linx with?

Which serial port? On your computer? On the Linx device?

 

What is the mainSerial and what is serial1?

Rolf Kalbermatter
My Blog
0 Kudos
Message 3 of 12
(2,821 Views)

Hello Rolf, 

First of all, many thanks for your reply and kind help.

 

I would like to use a arduino pro micro, wich is officialy supported in linx.

This device have built-in serial USB converter in the ATMega32U4 chip.

It works flowlessly over the USB port and USB cable, device regognized as "COM7" on my computer.

 

This device also have an additionnal HW serial. (TX and RX pin on pin 0 and 1).

If I connect a serial-USB adapter like FTDI converter on these pins, device is recognized as "COM8" on my computer.

 

Serial Communication is tested OK through both (built in USB  and HW TX and rx pins), with arduino basic examples.

But I need to call "serial" functions for COM over USB,  and "serial1" over the TX RX pins.

This is conform with the board spec / manual.

 

This is were I'am stuck, as Linx firmware use lower level function for the serial listener.

I've tried to change variables like numChan in device .h files, without success so far.

 

 

The reason why I want to use the HW port (pin 0-1) is that I'll use a wireless connection to replace the cable. (wireless serial), with HC 05 BT or HC12 radio module).

NB : I can make this wireless connection with no pbm if I use an arduino pro mini. (wich has no built -in serial/usb converter)

 

I hope it's more clear many thanks !

 

Antoine

 

0 Kudos
Message 4 of 12
(2,809 Views)

Hello mknix.

 

I believe that the built in serial USB converter and the pins 0 an 1, are the same thing.

When you say: "Serial Communication is tested OK through both (built in USB  and HW TX and rx pins), with arduino basic examples." did you mean at the same time?

 

one possibility to solve this problem is to use SoftwareSerial Library in you Arduino Program, and create other pins rather than 0 and 1 Tx RX.

 

Jorge Augusto Pessatto Mondadori, PhD
Sistema Fiep
CLAD, CLD
0 Kudos
Message 5 of 12
(2,796 Views)

thanks a lot Jorge for your feedback

 

Jorge wrote : [I believe that the built in serial USB converter and the pins 0 an 1, are the same thing]

 

I also believed this at the beginning.

But after digging more into it, it is not the case.

 

It's thrue for some board like uno, nano... wich have only one HW serial.

But some other boards (leonardo, micro, mega etc) have two or more HW serial.

see the table here :

https://www.arduino.cc/reference/en/language/functions/communication/serial/

 

mknix_0-1613572089359.png

you can see that micro (and pro micro) have serial over USB, and serial 1 over TX and RX pin.

 

Jorge wrote : [one possibility to solve this problem is to use SoftwareSerial Library in you Arduino Program, and create other pins rather than 0 and 1 Tx RX.]

 

I alredy used softwareserial for other projects in the past, but unfortunately it is not that simple here (as far as i tried, I'am not expert).

Seriallistener is the heart of linx, really optimised for the performance.

 

As the board have two HW serial, I believe (maybe wrong?) that we can route the serial flow to the second serial HW port, instead of emulating a software serial. (wich is not easy anyway).

But I don't know how to do this 😉

 

thanks again for your help !

 

 

 

 

 

 

 

0 Kudos
Message 6 of 12
(2,793 Views)

It's not enough to change the NUM_UART_CHANS value in the according header file. You also need to extend the according

LinxArduinoXXXX::m_UartChans[NUM_UART_CHANS] = {0, 1};

in the corresponding c source file. Most sources for the different Arduino files only define one uart for uart 0.

 

The underlaying LinxWiringDevice class implements Serial, Serial1, Serial2, Serial3 for Linx Uart channels 0, 1, 2, 3 respectively.

 

Only the LinxArduinoMega class supports all 4 out of the box but you do not want to use that one for your device unless it also has ArduinoMega compatible DIO pins too.

Rolf Kalbermatter
My Blog
Message 7 of 12
(2,777 Views)

Thank you so much Rolf.

 

This is exactly what I was looking for.

It still doesn't work, but I got the feeling that I'am very close 😉

I have searched in the library of my board for "NUM_UART_CHANS"

I get 4 results (here for a try with a leonardo):

mknix_0-1613583314917.png

in LinxArduinoLeonardo.h

I changed : 

#define NUM_UART_CHANS 2   // was 1

 

 

in LinxArduinoLeonardo.cpp

I changed : 

unsigned char LinxArduinoLeonardo::m_UartChans[NUM_UART_CHANS] ={0, 1}; // was ={0}, replaced by ={0, 1}

 

 

in LinxConfig.h

I changed : 

#define NUM_UART_CHANS 2 // was 1

 

 

in LinxWiringDevice.cpp

I changed  nothing, as it seems bo be were the serial mode is selected (0, 1 etc), based on variable "channel"

mknix_1-1613583567035.png

 

This is unfortunately not enough. Datas still flows over serial instead of serial 1

I'am not clear were the value of "channel" is set. Could this be the clue?

 

Again thanks !

 

Antoine

 

 

 

 

 

0 Kudos
Message 8 of 12
(2,761 Views)

Hi Antoine,

Is the channel set in 

Arduino_Leonardo_Serial.ino ?

 

Message 9 of 12
(2,751 Views)

Hello AndyLB

Thanks for helping.

 

yes, I tried 

LinxSerialConnection.Start(LinxDevice, 0); 

and 

LinxSerialConnection.Start(LinxDevice, 1);

In Arduino_Leonardo_Serial.ino

 

Both makes the same result

 

thanks a lot for the good hint anyway

0 Kudos
Message 10 of 12
(2,740 Views)