Problem to use Arduino UNO library modbus on an Arduino ZERO

Thread Starter

BRUNET Joss

Joined Nov 1, 2018
38
Hello everyone,

I try to use this library : https://github.com/jossef/arduino-modbus-slave/tree/master/ arduino-modbus-slave (for Arduino UNO) with an Arduino ZERO. And it don't works correctly(I meet a random problem : lenght error or unknow error when I proceed to a modbus communication between Arduino and PC with CAS Modbus Scanner software).

Furthermore, I use a MAX1485 connected to Arduino ZERO (mode half-duplex). So, I have added an output TX control with a GPIO to control the MAX1485 in the library, see below:

Code:
//if a reply was generated
    if(_len)
    {
        int uu;
        digitalWrite(7, HIGH);
        for(uu = 0 ; uu < _len ; uu++)
                Serial1.write(_msg[uu]);
      
        Serial1.flush();
        digitalWrite(7, LOW);

        //free the allocated memory for the reply message
        free(_msg);
        _msg = NULL;
        //reset the message length
        _len = 0;
        Serial.println("Reply ok");
    }

I have to use the ZERO, so, I would like found a solution.

Thank's
Joss
 

shteii01

Joined Feb 19, 2010
4,644
U have two choices. Find library for zero. Or. Modify uno library to work for zero.

Or write your own code to do what u need done.
 

Thread Starter

BRUNET Joss

Joined Nov 1, 2018
38
Yes, I understand well. In my case, for facility reason, I would like keep this library.
So, I’m looking for solutions/advices because I’m blocked.

Thanks,
Joss
 

spinnaker

Joined Oct 29, 2009
7,830
Yes, I understand well. In my case, for facility reason, I would like keep this library.
So, I’m looking for solutions/advices because I’m blocked.

Thanks,
Joss

I will give you another choice. Modify the code to make it work for you. The source is supplied.
 

Thread Starter

BRUNET Joss

Joined Nov 1, 2018
38
Thank’s for answers.

Ok, I have understand. But, I came on this forum to have help. I have already try to modify the source but I don’t found a solution after some days of work.

More often, basic library is compatible between Arduino. But this is not my case today.

My actual modbus library uses the serial peripheral of Arduino, and I don’t know how to achieve a debug on my problem.

I’m looking for solutions/advices...
 

spinnaker

Joined Oct 29, 2009
7,830
There is help and there is someone doing your work for you. We will help. We won't do your work for you. You want someone to do your work for you and that is not going to happen.
 

Thread Starter

BRUNET Joss

Joined Nov 1, 2018
38
I don’t want to give that impression. I’m sorry.

I will try again, but I have a lack of knowledge in this field. I came here to find solution (if a people has already found a solution) or advice to help me in my problem (like: check the difference between size buffer between UNO and ZERO or how to realize a debug on serial buffer).

Thanks for your recommandation.
 

Thread Starter

BRUNET Joss

Joined Nov 1, 2018
38
Thank you shteii01.

I have installed the library below :

upload_2018-12-15_0-3-39.png

To use watchdog library below :

upload_2018-12-15_0-5-40.png

U think that can modify UART working ? Or that a timer used by watchdog function can degrade the UART ?
 

Thread Starter

BRUNET Joss

Joined Nov 1, 2018
38
Ok, I just checked, I have already installed this library. So, I have proceed to an update in v1.6.20.

As soon as possible, I will do a test with disabled watchdog.

I specify that my modbus works half time. And it is for this reason that the problem is hard to find.
 
Top