Modbus RTU function 1 code

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.

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

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).

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.

The link attachded there is no code for function1 .

Bullshit, it's just called differently: FC_READ_COILS.

pylon:
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?

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.

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

AJITnayak:
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.

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.