ganehag / pyMeterBus

Pure Python implementation of the Meter-Bus (M-Bus EN13757-3) protocol.
BSD 3-Clause "New" or "Revised" License
77 stars 40 forks source link

Can we change to accept 115200 baud rate? #6

Closed loverboy80 closed 6 years ago

loverboy80 commented 6 years ago

Hi,

Your pure Python implementation is very robust and well thought out. We would like to use this for a device running a baud rate of 115.2k.

Do you know if your code can be configured by us to accept a higher baud rate than your upper limit of 38400? In particular, it's the constants for the hex values that we set for 115200 baud. The code uses 300 = 0xB8, up to 38400 = 0xBF. Do you have any light you could shed on a hex value for 115200 as I tried 0xC1 and got an error. Sorry for my ignorance it seems but I havent been able to find the equivalent hex value for 115200 anywhere in the MBUs standards.

Any advice you could provide would be great! Thanks .

ganehag commented 6 years ago

Hi,

Nice to know some people are finding this library useful.

The M-Bus specification does not support a baud rate higher than 38400. You can find a table with the allowed speeds here from the official documentation.

In the real world, I have never seen the use of any baud rate other than 300, 2400 and 9600 (reason). It was after all designed for hardware from almost 30 years ago (around 1990). Back then, 38400 was pretty much today's equivalent of having Fibre Channel in your workstation.

If the slave is pre-configured to run at 115200 baud (out of spec.), communicating with it at that speed will/should still work. There is just no way to send a control frame with that speed, within the specification of the M-Bus protocol.

I hope it answers your question.

loverboy80 commented 6 years ago

Hi Mikael,

Yes, its very useful thank you once again.

Thanks for the direction you have provided here not just for myself but other programmers new to MeterBus industry and specifications.

Yes, your response absolutely answers the question I posed to you about why we cannot go above the 38400 baud limit with respect to proper MBus implementation here.

And I believe it is the case you mentioned that our slave devices are preconfigured for 115200.

Whilst we cannot send control frames that match 115200 speed can you suggest where we can safely change to 115200 in your implementation without breaking the working code? I would be happy to possibly post the varied working code up then marked as a collaboration with you.

I accept your decision either way.

Thanks again Mikael,

Nic

ganehag commented 6 years ago

Using 115200 baud is something you have to handle in your code.

If you take a look in here for example, the code is as follows (simplified):

device = "/dev/ttyUSB0"
baudrate = 115200
address = 254
with serial.serial_for_url(device, baudrate, 8, 'E', 1, timeout=1) as ser:
    meterbus.send_ping_frame(ser, address)  # or something else

That should be all that you need to have a PySerial object with the correct baud rate.

/Mikael

loverboy80 commented 6 years ago

Yes . Of course :) ok thank you Mikael please forgive my ignorance. It was right there . tack så mycket vän!  

Sent from my Samsung Galaxy smartphone. -------- Original message --------From: Mikael Ganehag Brorsson notifications@github.com Date: 27/4/18 16:34 (GMT+10:00) To: ganehag/pyMeterBus pyMeterBus@noreply.github.com Cc: loverboy80 noogietime@gmail.com, Author author@noreply.github.com Subject: Re: [ganehag/pyMeterBus] Can we change to accept 115200 baud rate? (#6) Using 115200 baud is something you have to handle in your code. If you take a look in here for example, the code is as follows (simplified): device = "/dev/ttyUSB0" baudrate = 115200 address = 254 with serial.serial_for_url(device, baudrate, 8, 'E', 1, timeout=1) as ser: meterbus.send_ping_frame(ser, address) # or something else That should be all that you need to have a PySerial object with the correct baud rate. /Mikael

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or mute the thread.

{"api_version":"1.0","publisher":{"api_key":"05dde50f1d1a384dd78767c55493e4bb","name":"GitHub"},"entity":{"external_key":"github/ganehag/pyMeterBus","title":"ganehag/pyMeterBus","subtitle":"GitHub repository","main_image_url":"https://cloud.githubusercontent.com/assets/143418/17495839/a5054eac-5d88-11e6-95fc-7290892c7bb5.png","avatar_image_url":"https://cloud.githubusercontent.com/assets/143418/15842166/7c72db34-2c0b-11e6-9aed-b52498112777.png","action":{"name":"Open in GitHub","url":"https://github.com/ganehag/pyMeterBus"}},"updates":{"snippets":[{"icon":"PERSON","message":"@ganehag in #6: Using 115200 baud is something you have to handle in your code.\r\n\r\nIf you take a look in here for example, the code is as follows (simplified):\r\n\r\npython\r\ndevice = \"/dev/ttyUSB0\"\r\nbaudrate = 115200\r\naddress = 254\r\nwith serial.serial_for_url(device, baudrate, 8, 'E', 1, timeout=1) as ser:\r\n meterbus.send_ping_frame(ser, address) # or something else\r\n\r\n\r\nThat should be all that you need to have a PySerial object with the correct baud rate.\r\n\r\n/Mikael"}],"action":{"name":"View Issue","url":"https://github.com/ganehag/pyMeterBus/issues/6#issuecomment-384878445"}}}