stephane / libmodbus

A Modbus library for Linux, Mac OS, FreeBSD and Windows
http://libmodbus.org
GNU Lesser General Public License v2.1
3.33k stars 1.71k forks source link

modbus_rtu_set_serial_mode() need to be called after modbus_connect() #42

Closed niclask closed 11 years ago

niclask commented 12 years ago

modbus_rtu_set_serial_mode() needs to be called after modbus_connect(). Can't find this information in the documentation. Another option is to change the function modbus_rtu_set_serial_mode() to be able to be called as long as there is a valid modbus_t* and have modbus_connect() to obey and set the mode as well. Regards

heymatias commented 12 years ago

Hi, I have the same problem, but, when I call modbus_rtu_ser_serial_mode() after modbus_connect(), setting RS485 mode, modbus_rtu_set_mode() return -1 and I have this error: "Invalid argument".

Know you what is happening with this?

I just starting with modbus and libmodbus, but I think I can't get anything :(

thanks, and have a nice day, even if you can't help me :)

niclask commented 12 years ago

Do you have correct backend type?

heymatias commented 12 years ago

How can I know?

I try a lot of things, nothing working :( even other programs can't work.

Need I enable something to use RS485? I connect the two cables from the port to the other PC, I think the hardware is fine.

niclask commented 12 years ago

Do you have a RS485 port in your computer and the correct module loaded in the kernel?

heymatias commented 12 years ago

I have a RS485 port, I'm sure... but I don't know anything about a kernel module. My mother is a Advantech PCM, I haven't the model right now, I'm in my home. But, know you how can I find the appropriated kernel module for my RS485 Port/PCM?

heymatias commented 12 years ago

This is my PCM http://www.advantech.com/products/PCM-9361/mod_85308674-6046-4B8C-B7FB-1CFAD6DAD057.aspx and I configure the jumper to use 485 and take the 2 cables from the COM2 without plug.

I will search again, but I don't see anything in documentation about a kernel module.

I did a lsmod, and I have this

Module Size Used by
binfmt_misc 6587 1
snd_hda_codec_realtek 203472 1
snd_hda_intel 22069 2
snd_hda_codec 74297 2 snd_hda_codec_realtek,snd_hda_intel
snd_hwdep 5412 1 snd_hda_codec snd_pcm_oss 35308 0 fbcon 35102 71
tileblit 1999 1 fbcon font 7557 1 fbcon bitblit 4707 1 fbcon softcursor 1189 1 bitblit snd_mixer_oss 13746 1 snd_pcm_oss vga16fb 11385 0 vgastate 8961 1 vga16fb snd_pcm 70694 3 snd_hda_intel,snd_hda_codec,snd_pcm_oss snd_seq_dummy 1338 0 snd_seq_oss 26722 0 snd_seq_midi 4557 0 snd_rawmidi 19056 1 snd_seq_midi snd_seq_midi_event 6003 2 snd_seq_oss,snd_seq_midi arc4 1153 2 snd_seq 47263 6 snd_seq_dummy,snd_seq_oss,snd_seq_midi,snd_seq_midi_event snd_timer 19130 2 snd_pcm,snd_seq i915 290035 3 snd_seq_device 5700 5 snd_seq_dummy,snd_seq_oss,snd_seq_midi,snd_rawmidi,snd_seq drm_kms_helper 29329 1 i915 rtl8187 50680 0 snd 54244 16 snd_hda_codec_realtek,snd_hda_intel,snd_hda_codec,snd_hwdep,snd_pcm_oss,snd_mixer_oss,snd_pcm,snd_seq_oss,snd_rawmidi,snd_seq,snd_timer,snd_seq_device drm 163779 4 i915,drm_kms_helper mac80211 205434 1 rtl8187 led_class 2864 1 rtl8187 soundcore 6620 1 snd snd_page_alloc 7076 2 snd_hda_intel,snd_pcm i2c_algo_bit 5028 1 i915 intel_agp 24375 2 i915 cfg80211 126528 2 rtl8187,mac80211 eeprom_93cx6 1333 1 rtl8187 video 17375 1 i915 output 1871 1 video ppdev 5259 0 agpgart 31724 2 drm,intel_agp parport_pc 25962 1 lp 7028 0 psmouse 63677 0 serio_raw 3978 0 parport 32635 3 ppdev,parport_pc,lp reiserfs 225508 3 r8169 34140 0 mii 4381 1 r8169

I think it's a lot of modules, but I don't care it right now.

stephane commented 11 years ago

The Google group (mailing list) of libmodbus is a better place to talk about various issues.