modbus

MODBUS RTU CRC16 calculation

核能气质少年 提交于 2019-12-24 07:45:26
问题 I'm coding a MODBUS CRC16 calculator in C. What I have before is a python that do this, I wanted to convert it to C. I found some codes online but it's not giving me the correct answer. For my python code, I have this as my CRC16.py #!/usr/bin/env python def calc(data): crc_table=[0x0000,0xC0C1,0xC181,0x0140,0xC301,0x03C0,0x0280,0xC241,0xC601,0x06C0,0x0780,0xC741,0x0500,0xC5C1,0xC481,0x0440,0xCC01,0x0CC0,0x0D80,0xCD41,0x0F00,0xCFC1,0xCE81,0x0E40,0x0A00,0xCAC1,0xCB81,0x0B40,0xC901,0x09C0

MODBUS RTU CRC16 calculation

邮差的信 提交于 2019-12-24 07:43:53
问题 I'm coding a MODBUS CRC16 calculator in C. What I have before is a python that do this, I wanted to convert it to C. I found some codes online but it's not giving me the correct answer. For my python code, I have this as my CRC16.py #!/usr/bin/env python def calc(data): crc_table=[0x0000,0xC0C1,0xC181,0x0140,0xC301,0x03C0,0x0280,0xC241,0xC601,0x06C0,0x0780,0xC741,0x0500,0xC5C1,0xC481,0x0440,0xCC01,0x0CC0,0x0D80,0xCD41,0x0F00,0xCFC1,0xCE81,0x0E40,0x0A00,0xCAC1,0xCB81,0x0B40,0xC901,0x09C0

Modbus-tk RTU Slave holding register read signed integer

泪湿孤枕 提交于 2019-12-24 03:32:15
问题 I created a modbus slave using modbus-tk as below. I use Simply modbus master software(http://www.simplymodbus.ca/RTUmaster.htm) as the master. How to set the slave to represent a signed integer instead of an unsigned. For example, when I send a 16 bits data, (FC19) HEX should represent -999 decimal , but now I get 64537. Try to use the example here https://github.com/ljean/modbus-tk/blob/master/examples/tcpmaster_example.py. It seems to only work for Master. import sys import modbus_tk

HEX/Decimal to date and time from modbus

本秂侑毒 提交于 2019-12-24 03:07:29
问题 I have a modbus connection to a ventilation system where it generates alarmas when something is wrong. I can with modbus receive data about the alarm. That part is documentated with a register for ID, date and time. All tre receives contains 2 byte of data. ID 00:13 (witch is converted to decimal error code 19 = Filter alarm) But i cannot figure out what format the date and time are in. However i can at the ventilation system see what these dates and times are translated to at the display.

pymodbus Exception Response(131, 3, IllegalAddress)

倾然丶 夕夏残阳落幕 提交于 2019-12-23 13:09:10
问题 I'm trying to run this piece of code: from pymodbus.client.sync import ModbusSerialClient as ModbusClient import logging logging.basicConfig() log = logging.getLogger() log.setLevel(logging.DEBUG) client = ModbusClient(method='rtu', baudrate=9600, parity='E', port='/dev/ttyUSB0', timeout=1) client.connect() rr = client.read_holding_registers(40000, 7, unit=0x01) print rr client.close() But I get only this: DEBUG:pymodbus.transaction:Running transaction 1 DEBUG:pymodbus.factory:Factory

How to find a COM port via CommPortIdentifier

左心房为你撑大大i 提交于 2019-12-23 03:44:27
问题 I am new with the whole modbus and serial communication concept so even if this is a really noob question please bear with me! Ok so I am trying to read values stored on a register, using modbus protocol and RS 232 port. I have written this code, but it is not finding serial port "COM 4" . What am I doing wrong? String wantedPortName = "COM 4" ; Enumeration portIdentifiers = CommPortIdentifier.getPortIdentifiers(); CommPortIdentifier portId = null; while (portIdentifiers.hasMoreElements()) {

Modbus Serial Port Data Reading in C#

北慕城南 提交于 2019-12-23 02:26:18
问题 Hi I am trying to read the Serial Port Data. I used NModbus library for the modbus communication. Code works fine for read and write purpose. But sometimes i am having some unknown errors and i wanted to see the serial port activity. I tried using the SerialDataReceivedEventHandler but i am not getting anything from the port but still i am able to read the value of the holding registers. Here is my code. All i want to see the data packet being sent / received over the serial port. namespace

J2Mod basic Master and Slave Questions

不羁的心 提交于 2019-12-22 12:54:21
问题 I am trying to make an Modbus Slave and Master using j2mod(it's version 1.0.6 tho, so that is compatible with another program), and i do have some general questions about the code i found online. I have found almost no useful documentation what so ever, so I'm kind of clueless. TcpMaster this.addr = InetAddress.getByName("127.0.0.1"); conn = new TCPMasterConnection(addr); conn.setPort(port); conn.connect(); req = new ReadInputDiscretesRequest(ref, count); trans = new ModbusTCPTransaction(conn

How to write to PLC input registers using pymodbus

我的梦境 提交于 2019-12-22 10:31:38
问题 I want to write to PLC input registers using pymodbus. I am able to read them : from pymodbus.client.sync import ModbusTcpClient client = ModbusTcpClient('10.10.10.32') client.connect() reg = client.read_input_registers(1,5) print(reg.registers) But I still did not found any way how to write any value to them. I appreciate any help. Thanks. 回答1: Input registers are read-only. You can write to holding registers, using Modbus functions Write Single Register or Write Multiple Registers

Need modbus Java library

对着背影说爱祢 提交于 2019-12-21 04:04:47
问题 I need simple modbus Java library with source code. I found on google but there is .jar file and doesn't have strong using manual. Can anybody suggest me modbus library with using manual or source code ? 回答1: Try this one: http://sourceforge.net/projects/jamod/files/jamod/1.2/ By the way, you can use JDGUI to see the sources of any jar file. 回答2: You can try Jamod. I never used it, but a colleague of mine used it sometime ago and he was pleased with it. 回答3: FieldKit is paid and open source,