-
Notifications
You must be signed in to change notification settings - Fork 21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Documentation #1
Comments
Hey! I've added a few examples to the example/ directory. Check out the verbose-init-tcp-ip.js especially, as it also has some comments. The automated tests are not finished, so there may be bugs. Some features (like functions for handling of repeatable transactions) are not yet present. As I was writing the code, I've tested it against Modbus PLC Simulator (can be used to quickly run the examples), some Delta PLC (Serial+ASCII, Serial+RTU, TCP+IP), Array APB PLC and Delta+Moxa NPort (TCP+ASCII -> Serial+ASCII, UDP+ASCII -> Serial+ASCII...). The proper readme and documentation will be done after 100% test code coverage, which in turn may be done if I'll have to do another application that requires MODBUS. Until then, feel free to ask any questions here ;) |
Do you have any examples using Serial RTU? The project looks pretty solid however I am struggling with reading and writing holding registers over serial RTU. Any small example using your project would be wonderful. |
You'll need node-serialport:
Then, create the master like so: var SerialPort = require('serialport').SerialPort;
var modbus = require('h5.modbus');
var serialPort = new SerialPort('/dev/ttyUSB0', {
baudRate: 9600,
dataBits: 8,
stopBits: 2,
paritry: 'none'
});
var master = modbus.createMaster({
transport: {
type: 'rtu',
eofTimeout: 10, // End of frame timeout
connection: {
type: 'serial',
serialPort: serialPort
}
}
});
// ... |
Thanks for the quick reply. I will fiddle about and let you know how everything goes. |
Thanks again for the help. One more question (then I think I am good to get this rolling on my own). I am attempting to connect to my device and just read a single holding register, however immediately after running
Have you ever seen this while working with the library? What was the general cause of it to not want to communicate? I have tested that the device does communicate properly on windows with other software via modbus RTU. I appreciate your time. Thanks, rlemon. |
You have to listen for the
If you have a lot of timeout errors, then try to increase the timeout options until they are gone (master's |
Sorry to continue to bother you. We're having some real issues - I presumed to change the slaveID I would change the unit in the Transaction Options.. but reading the stream on the other end I'm seeing the slave as |
master.readHoldingRegisters(0, 1, {unit: 1}) What Connection and Transport are you using? Serial RTU? |
Sorry false alarm. I have another gentleman working on this with me and he hard coded the unit in the Transaction file to 13 (and tera term makes D and 0 look incredibly alike) - So we were actually seeing 0D (13) - reverted the file and it works as expected. |
Sorry, to bother you. I'm working along side rlemon on this code. Unfortunately, as it stands the modbus library defaults to START_LOW_COIL = 1, but we want it to start at 0. Here's my calling procedure:
Is there a default variable, analogous to 'timeout' or 'unit' in the code sample above, that we can specify to force it to start at 0? The frame data it currently outputs is: "01 03 00 01 00 01 D5 CA". Thanks |
Why don't you pass // readHoldingRegisters(address, quantity, options)
master.readHoldingRegisters(1, 1, {unit: 1})
// results in frame
// 01 - unit
// 03 - function code
// 00 01 - address
// 00 01 - quantity
// D5 CA - checksum
master.readHoldingRegisters(0, 1, {unit: 1})
// should result in frame
// 01 - unit
// 03 - function code
// 00 00 - address
// 00 01 - quantity
// xx xx - checksum |
Awesome!!! It works!!! Thanks a bunch. |
I have a terminal monitoring packets sent and received and I am finally getting a response packet from the slave of: 01 03 02 00 00 B8 44
Is there anyway that I can dump or check if data is received? Thanks in advance. |
Modbus RTU separates frames by not sending anything for a specific amount of time ("at least 3 1⁄2 character times of silence between frames", see Wikipedia). I don't think you can wait 3 1/2 character times in Node.js so I've introduced the You have set the Try setting the |
That did it!!! Thanks again. |
Hey, do you have any examples of using ascii? I have been successfully using your rtu example but switching over to ascii I keep getting a "ResponseTimeoutError". I connected a network analyzer and my device is getting everything correct, I just can't figure out how to tell the listener that there is a response waiting. |
Hey! Try increasing the master's |
Thanks for the quick response! Did a complete wipe of my source and that fixed it. I must have tried modifying something in the h5.modbus source. Responses are coming through in ~50 ms now so the defaultTimeout wasn't the issue (I was...). |
Should 'eofTimeout' be a function of the baud rate?... |
It should, but it won't work in node.js. For baud rates >= 19200 it should be 1.75 ms, for 9600 - 3.65 ms. Node isn't reliable with such small timers, so you should just test what is the smallest value that works for you. |
Hey, |
Look into the example/ directory or check out any project of mine that is using this library. |
I am interested in this project. |
The one from the master branch won't work (unless you transpile it using something like Babel). The old version will work: https://github.com/morkai/h5.modbus/tree/v0 |
I am very interested in your project, as it only meets my requirements.
Could you write a small documentation for me.
Thanks in advance.
The text was updated successfully, but these errors were encountered: