rscada / libmbus

Meter-bus library and utility programs
http://www.rscada.se/libmbus
BSD 3-Clause "New" or "Revised" License
224 stars 138 forks source link

Timeout problem for 2400 baud #124

Closed btrhad closed 7 years ago

btrhad commented 7 years ago

I am using libmbus on a Beaglebone black and had no problems in retrieving data from various meter types. Until I encountered a GWF UniCocoder water meter. This meter is fixed at 2400 baud. I was able to do an address scan, but an serial-request-data at 2400 baud always failed. Checking with a scope I found the device was sending a correct response, but the Beaglebone as master was not able to parse the response. I found out the Timeout for 2400 baud in mbus_serial_set_baudrate() was just a little bit to short. Changing handle-t.c.c_cc[VTIME] from 2 to 3 solved the problem.

lategoodbye commented 7 years ago

@btrhad I want to know more about your setup (starting from Beaglebone until M-Bus wire). What kind of M-Bus master do you use? Do you use Linux on the Beaglebone?

Edit: Sorry, it's not your job but i don't access to a M-Bus setup, but could you please dump the return value of tcdrain by patching mbus-serial.c with your setup:

ret = tcdrain(handle->fd);
fprintf(stderr, "tcdrain = %d\n", ret);
btrhad commented 7 years ago

Hi Stefan,

We use beaglebone black (rev C), with this cape: http://elinux.org/Apli_Hvac_cape (mbus/modbus) wich contains this mbus master interface: http://www.solvimus.de/smart-metering/m-bus-oem-master/ We use linux 4.4.30-ti-r64 kernel with debian 8 (Jessie) this is the beagleboard.org shipped default. And we add rscada/libmbus software.

Please let me know if I need to provide more info

Met vriendelijke groet, With kind regards, Betronic BV

Henk Dijkstra Manager Connectivity Solutions ü Pleasehttp://www.betronic.nl/jahia/Jahia/lang/en/pid/153 consider the environment before printing this e-mail

From: Stefan Wahren [mailto:notifications@github.com] Sent: vrijdag 7 april 2017 16:05 To: rscada/libmbus Cc: Henk Dijkstra; Mention Subject: Re: [rscada/libmbus] Timeout problem for 2400 baud (#124)

@btrhadhttps://github.com/btrhad I want to know more about your setup (starting from Beaglebone until M-Bus wire). What kind of M-Bus master do you use? Do you use Linux on the Beaglebone?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://github.com/rscada/libmbus/issues/124#issuecomment-292545507, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AZww2DilHB6I7F-TD-GWOujuzaRqUYusks5rtkKZgaJpZM4M26dD.

lategoodbye commented 7 years ago

@btrhad Could you please try this branch (which contains your suggestion):

https://github.com/rscada/libmbus/tree/serial-timeout

btrhad commented 7 years ago

I can do that next week, don't have The module now at hand. I Will inform you of The result. Ps i also noted that The First req-ud2 starts with The fcb bit cleared, while all other mbus master sw starts with this bit set. Does this sound familiar?

Verstuurd vanaf mijn iPhone

Op 7 apr. 2017 om 18:08 heeft Stefan Wahren notifications@github.com<mailto:notifications@github.com> het volgende geschreven:

@btrhadhttps://github.com/btrhad Could you please try this branch (which contains your suggestion):

https://github.com/rscada/libmbus/tree/serial-timeout

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://github.com/rscada/libmbus/issues/124#issuecomment-292579189, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AZww2BMdobp99cTxkyIXDRlrwDU5vQzGks5rtl97gaJpZM4M26dD.

lategoodbye commented 7 years ago

I created a branch to fix FCB handling:

https://github.com/rscada/libmbus/tree/fix-fcb-handling

but didn't get positive feedback. In case there is a real issue please feel free to open a new issue or at least try this branch, too.

btrhad commented 7 years ago

Hi Stefan,

This branch works fine with all the mbus meters I have in my possession (at 9600 baud) including the 2400 baud GWF meter. Secondary address scan now also works reliable (which was not the case with libmbus release 0.8.0)

I will monitor for the rest of the week, to check reliability.

Met vriendelijke groet, With kind regards, Betronic BV

Henk Dijkstra Manager Connectivity Solutions ü Pleasehttp://www.betronic.nl/jahia/Jahia/lang/en/pid/153 consider the environment before printing this e-mail

From: Stefan Wahren [mailto:notifications@github.com] Sent: vrijdag 7 april 2017 18:08 To: rscada/libmbus Cc: Henk Dijkstra; Mention Subject: Re: [rscada/libmbus] Timeout problem for 2400 baud (#124)

@btrhadhttps://github.com/btrhad Could you please try this branch (which contains your suggestion):

https://github.com/rscada/libmbus/tree/serial-timeout

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://github.com/rscada/libmbus/issues/124#issuecomment-292579189, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AZww2BMdobp99cTxkyIXDRlrwDU5vQzGks5rtl97gaJpZM4M26dD.

lategoodbye commented 7 years ago

I merged the serial-timeout branch into the master.