Go Down

Topic: Modbus RTU function 1 code (Read 244 times) previous topic - next topic

AJITnayak

Dear all,

I am looking for sample code written in c  for function code 1. to read data status of digital input .IS there any example code.

https://github.com/yaacov/ArduinoModbusSlave/blob/master/src/ModbusSlave.cpp

Below library in c++ , any similar code in function code1
AMPS

pylon

There are several libraries that implement the master and the slave side of ModBus. All I already inspected implement function 1 so there should be plenty of example code.

The Arduino IDE supports C++ so please specify why you're explicitly asking for C code. C++ is similar enough to extract the functionality if you really need C code (at least ANSI C, I hope you're not asking for K&R C).

AJITnayak

The link attachded there is no code for function1 . So is there any working library for which i can do code conversion from C++ to c.
AMPS

pylon

Quote
The link attachded there is no code for function1 .
Bullshit, it's just called differently: FC_READ_COILS.

adwsystems

Bullshit, it's just called differently: FC_READ_COILS.
Agreed. but the code looks a little thin. Has anyone used this library directly with success?

pylon

Quote
Agreed. but the code looks a little thin. Has anyone used this library directly with success?
That's because it just handles the ModBus specific parts and delegates the rest to callback functions. But to be clear: I haven't used it myself.

AJITnayak

There is no example code written for function code 1 with Arduino in C.
AMPS

adwsystems

There is no example code written for function code 1 with Arduino in C.
As mentioned previously, probably not since Arduino libraries are (typically) programmed in C++. You have a library with function 1 code programmed in C++ and I could easily find 2-3 more of the same. You haven't motivated anyone to help look as you have not stated why it must be in C and not C++. You are asking people to do extra work without providing them motivation (a reason) to do so.

pylon

Quote
There is no example code written for function code 1 with Arduino in C.
The library has example code available which also implements ModBus function 1. As you're asking for code for the Arduino platform it uses C++ as that's what the Arduino platform uses. If it must be C code you probably use AVRstudio but then ask the vendor for support.

Go Up