I/O possible

#include <modbus.h>

void main(int argc, char *argv[]){
int device = Mb_open_device("/dev/ttyUSB0",9600,1,8,1);
Mbs_data = (int *) malloc(1000*sizeof(int));
Mbm_trame test;
test.device = device;
test.slave = 0x01;
test.function = 0x03;
test.address = 0x01;
test.length = 0x3C;
test.timeout = 10000;
Mb_slave(device,1,NULL,NULL,NULL);
int wynik=Mb_master(test,NULL,Mbs_data,NULL,NULL);
printf("%d\n",wynik);
int i;
for(i=0;i<60;i++) printf("%d\n",Mbs_data[i]);
Mb_close_device(device);
}

And I get always I/O possible.
Mb_master(test,NULL,Mbs_data,NULL,NULL); throws it.. why?
The lib is http://pes.free.fr/libmodbus.html#2

Please help
I can't seem to find a link to download the library source, so i can't tell when this Exception is raised.

I'm personnally using this library and am happy with it
http://libmodbus.org/
I'm personnally using this library and am happy with it
http://libmodbus.org/


I'v never actually heard of this lib. before(just saying I'm not sure how many here know about his library)

You might have more luck on the actual forum for it...
Last edited on
I've tried but I don't get nothing...
modbus_new_rtu("/dev/ttyUSB0",115200,'E',8,1);
modbus_connect(mb);
modbus_set_slave(mb,0x01);
modbus_read_registers(mb,0,73,tr);
...
I get always something in tr[42] tr[43] and from tr[56]... to somewhere
Why?
It doesn't matter if I set slave 1, 2 or enything. (my device is 1)
Last edited on
I'm using an older version of libmodbus actually, so i'm not used to those function names. And i can't help much with only this code. Also, what kind of slave are you connecting to, and are you sure about what is in the registers you try to read?
If you 'get something' regardless of the slave number, i think you are actually getting nothing, maybe you just see the previous values in tr
One error i can see is that you don't assign the return of modbus_new_rtu to mb, so the following functions can't use mb
Topic archived. No new replies allowed.