-
-
Notifications
You must be signed in to change notification settings - Fork 267
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
Modbus conection error #1694
Comments
There seems to be an issue with the updated MODBUS lib underlying Artisan which moved to a more strict interpretation of the MODBUS specification regarding inter character timing which seems to break some of our MODBUS communication over serial. I tried to work around this. Could you please test and report if the current continuous build works any better for you. There is a new "strict" flag in the serial section of the MODBUS tab which is by default not ticked. The new MODBUS lib default is used if it is ticked. |
Thank you for the quick reply. Unfortunately the Modbus connection doesn't work in 3.0.3 either. |
Hm. Not so good. In that case I need some detailed logs. Please activate Artisans debug log mode by clicking on the plus icon in the left corner while holding the CTRL and ALT keys. Then also activate the device logging by ticking "Logging" in the Device dialog (menu Config >> Device). Now turn Artisan ON and let it run for some 10sec. Turn Artisan OFF and click again the plus icon, this time holding only the ALT key. An email should open with the log files attached. Send them to the given receiver. I am quite sure that Artisan v3.0 will work for you as it is still based on the previous MODBUS lib version. Maybe you can confirm this too. |
So i can`t find a download of the Artisan V3.0.0 (only sourcecode) In the V3.0.2 and the V3.03 (with strict-flag) did not work the Modbus connection. Now I go back to the 2.10.4 Thanks I can`t send the logfiles (there is an error) |
These are the Lod files with V2.10.4 |
Those log files don't show the error as there no problems running v2.10.4. To resolve the issue for current later Artisan versions we need a log of the errors which hopefully contain information on how to fix this. For this you need to run the test (with those two debug settings activated) on the problematic Artisan v3.0.2 (or Artisan v3.0.3). |
The Log-files with v3.0.2 are these: |
Thanks for those logs. Sadly it only states that it never received anything from the device
|
The log files also do not seem to complete. They should be exactly 800KB but are only less then half this size. Very strange! |
I have now found the download for v3.0.0.0 and installed this release. Attached are the log files with V3.0.0.0 with some actions on the machine. |
Now I have tested the new cotinius build 3.0.3 from roasterdave. |
In you logs I only see that Artisan did not receive any thing from your device. Could you please download the latest continuous build v3.0.3 again (same name, don't get confused) as I applied some changes that could help to sort this out. On testing, please keep the debug settings ON. THANKS! |
Sorry, it do not work. What means in the log file this lines? 09-18 19:09:39 Dummy-2 pymodbus.logging ERROR : could not open port 'COM4': FileNotFoundError(2, 'Das System kann die angegebene Datei nicht finden.', None, 2) |
Ok. Thanks anyhow for testing. I will take a look at the logs and see if I find something more.
M
… On 20. Sep 2024, at 15:06, ferihumh ***@***.***> wrote:
Sorry, it do not work.
The Connection always switch between
Verbunden ber MODBUS (5 sec)
MODBUS getrennt (3 sec)
artisan.log
artisanViewer.log
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you commented.Message ID: ***@***.***>
|
It's not a big problem for me. I wonder if another roaster also has a MODBUS problem with V3.0.3 With V.3.0.3 there is no communication at all between Artisan and slave (Arduino MEGA 2560). |
There was an issue reported by two users on v3.0.2 regarding serial MODBUS connections caused by an updated MODBUS lib which enforced the strict timing regime from the MODBUS specs. However, I did now work around this one to allow for non-strict timing if that corresponding new flag "Strict" in the serial section is turned off. This resolved the issue for two other users. The error message
indicates that your Windows did not generated the serial com port for your device (or it is not COM4) and thus Artisan could not communicate at all with that serial device. How should it if the specified com port does not exists. This has nothing to do with MODBUS, but with the underlying serial communication and is obviously external to Artisan. You should investigate why in your v3.0.0 setup that comport is generated (is it COM4!) and in your v3.0.3 setup not. This must be totally external to Artisan. Could you please verify? |
Port 4 is present, tested and works correctly. I have now installed Artisan V3.0.3 again and created log files. Both log files only contain data that was recorded after the installation of V3.0.3. In the artisanViewer file, I habe found 2 confuse lines: 09-18 17:54:09 MainThread artisanlib.main INFO : serial: COM4 @9600 line 1 // right is COM4 @19200 |
The first line in your log reads
Why not share the full log containing this important information you refer to? The first of those lines states that the port used for serial communication is set to The second line is about the MODBUS serial communication you are using and which is configured in the MODBUS tab of the ports dialog (3rd tab). This one is configured to comm port COM8. Maybe this is the issue. You should choose on the left side of the MODBUS tab the correct comm port (COM4 in your case!?). |
You called? |
@9600 : Sorry, forgot to quote this serial baudrate in my comment. |
Wait a moment. You have entries in the ArtisanViewer log file!? Note that Artisan starts in Viewer mode if it detects that there is already one running. The ArtisanViewer is never connecting to any device (hence the name). Ensure that you have only one Artisan process running, that it is v3.0.3, that the correct serial port is selected in the MODBUS tab and test with this setup. Everything else is totally confusing. |
So, what is the actual situation? Sorry, but i guess that my software and hardware configuration settings are OK and work with artisan V2.0.0 up to V3.0.0 |
The only way we can find out what is going on is trying to duplicate the issue on our side. We have an Arduino mega ordered. Could you please provide us with your Artisan settings (save via menu Help >> Save Settings and attach here renamed to artisan-settings.txt) as well as your Arduino sketch. Thanks! |
Don't be afraid of the Arduino program. V3.0.0 is actually enough for roasting but the new versions also have new features in Artisan+ |
Will you provide a pointer to the correct ModbusRtu library and version used with your sketch? Thanks. |
The pointer in the sketch to the ModbusRtu.h in here: This is the library https://github.com/smarmengol/Modbus-Master-Slave-for-Arduino |
Got it, thanks. Investigating. |
I think we shouldn't waste too much time looking for the problem of my Modbus connection problems. I think the problem is due to my simle unprofessional Arduino sketch. It is therefore difficult to analyze the cause. On my side we can close this issue. I will let you know if there are any problems with the new sketch. |
- adds optional delay after connect before sending requests to serial MODBUS to allow to wait for Arduino slaves to complete reboot (Issue #1694)
We did analyze the issue over the weekend with various hardware and sketches. It turns out that the real issue is the Arduino restarting on opening a serial connection. Depending on the hardware and the sketch this takes a moment such that the first request send from Artisan fails. Sadly on recognizing the failed communication the MODBUS lib underlying Artisan disconnects and reconnects the serial connection which restarts the Arduino again. A large serial timeout could prevent this to happen, but has other negative consequences. We found the only solution is to introduce a user configurable delay after the serial connect and before sending the first request. For this we retired the current read A new continuous build v3.0.3 with this change is now only. We would love if you could give this a test using the following settings in MODBUS tab and give us feedback.
Two notes on your sketch and your MODBUS configuration:
|
Yes, I also had this suspicion that the artisan and the Arduino were constantly missing each other. The Modbus connection kept switching between connected and disconnected. Too little time for master and slave to exchange data, like "wait, I'll be ready in a minute" I am confident that your error analysis and changes in the continuous build will be successful. I will install the new build of artisan V3.0.3 this evening and use the recommended settings. Maybe it will take about 20:00 for feedback. Thank you for your accurate response and the extra shift over the weekend on this tricky difficult problem. |
Unfortunately, I can't establish a Modbus connection with the current build V3.0.3 either. I have tried various combinations of
Unfortunately, a Modbus connection was not possible with any combination. With V3.0.0 I even have a connection with this setting: But if I go with Timeout: 0.9, then no connection is possible, no matter what I enter for Delay or Retries. |
This is strange. I am able to solidly connect from Windows 11 to an Arduino Mega running your sketch (with the sensor code stripped since I don't have that hardware and the temperatures set constant, original delays intact). Using your settings file with:
Would you please attach your current artisan.log file (no need for artisanViewer.log) so we can take a look? |
This is the log file from this evening, with various attempts. After testing I go back to V3.0.0 I will now installing V.0.3 on my Windows Surface and trying your settings: Timeout: 0.4s After that I'll send feedback with the log file. It takes 30 minutes |
So, now I have install the continuous build V3.0.3 onto the Windows surface. This uses COM 3 for Modbus communication. I have set these settings: Unfortunately, NO connection to the machine (arduino mega) is possible. Staring from this line |
The log shows Artisan trying to open MODBUS on COM4, not COM3. Please double check the setting on the Modbus tab. Thanks. |
The COM3 is right. Arduine IDE con connect the board on COM3 Another current log file |
Did you try with a higher Delay, say 3sec. As I said, as high as needed, but as low as possible. It might take your Arduino longer to restart due to the other code you have around, like for the display and such. |
Okay, communication is taking place now on COM3. It looks like this startup delay is not long enough for your setup. I'd increase the delay to 3 and set retries to 2. If that still fails try a longer delay. |
Note that the 'Delay' parameters on 3.0.0 and 3.0.3 are different and serve different purposes. Only on the current v3.0.3 that parameter adds a delay (in seconds) after the connect to wait until the Arduino fully restarted and can start answering requests. On all versions before, that parameter only added a (small) extra delay (in milliseconds) after the last request. |
In V3.0.0 I can set various parameter combinations. The Modbus connection always works. In V3.0.3 it is the other way round. No matter what values I use, no Modbus connection is established. I think the problem is with the pymodbus library introduced in V3.0.2. Are there any other "Modbus" roasters that have already switched to V3.0.2? Is the Modbus connection working for anyone? |
The issue you encountered with Artisan v3.0.2 was caused by the update of the pymodbus lib to v3.7.x not supporting retries on empty answers any longer (remove unneeded client parameters: remove We added a delay after connect before sending the first request for serial connections which can resolve this issue. You might want to check out the continuous build. It is based on a more modern async variant of the same MODBUS lib which allows for retries without disconnects. This allows to connect to devices like your Arduino which drop requests the first seconds after a connect due to internal delays (a restart in your case). This update will be part of the next Artisan version. |
Ok, thank you very much for the information. I will test the Coniius bulds and try different delay times. I will also try to optimize the Arduino code for the new situation. |
Problem Description
With v2.10.4 my Modbus settings worked perfectly.
With v3.0.2 I get Modbus connection errors
What could be the cause?
I have now switched back to v2.10.4 and the MODBUS connection is now working perfectly again.
Steps To Reproduce
No response
Artisan Version
3.0.2
Computer OS and Version
Windows 11
Connected devices or roasting machine
DIY Roaster Arduino Mega
Files
A sample profile *.alog file, renamed to *.alog.txt is attached.
A settings file (Help>> Save Settings) *.aset, renamed to *.aset.txt is attached.
Screenshots are attached.
No files are attached.
The text was updated successfully, but these errors were encountered: