-
Notifications
You must be signed in to change notification settings - Fork 1
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
Disable or change debug output to USB serial? #7
Comments
Thanks for the feedback Luke. There was no way to disbale the debug messages. You had to manually search & replace all debug messages line as comments. But I just added a global switch for enabling and disabling the debug messges with the following code. // Enable/Disable debug messages here. 0 = Disabled, 1 = Enabled
#define DEBUG_ENABLED 1
// You can change the serial port for debug messages here
#define MODBUS_DEBUG_SERIAL Serial
// Define macros for printing debug messages
#if DEBUG_ENABLED
#define DEBUG_PRINT(x) MODBUS_DEBUG_SERIAL.print(x)
#define DEBUG_PRINTLN(x) MODBUS_DEBUG_SERIAL.println(x)
#else
#define DEBUG_PRINT(x)
#define DEBUG_PRINTLN(x)
#endif Now you can enable/disbale the debug messages by setting the You can clone the repository to your local |
Great, thank you. Any interest in making this something you pass in? That way I can use the standard library from the library manager and as it updates I don't have to make a separate copy and edit it each time. |
Definitely. I will push this to a new release. |
Sorry, to be more clear. An argument that can be passed in so the source files do not need to be edited. I don't think you can pass in a define. |
Ah that way! Yes, I will add that. |
Hi Luke. I implemented the dyniamic enable/disable for the debug messages on the fly. There is a new hlelper class called CSE_ModbusRTU_Debug:: enableDebugMessages();
CSE_ModbusRTU_Debug:: disableDebugMessages(); |
Awesome, do you have an example of how to use this? It does not appear to take a reference or pointer of the CSE_ModbusRTU class object. |
You don't have to use an object. Simply call the function exactly as shown in the previous reply. You can place it anywhere in your main code. If you want an example, check out the server test example in the |
Is there a way to turn off the debug data that is dumped to the USB serial port on every request?
Also wanted to let you know this project is absolutely awesome along with the documentation over at circuitstate. I was pulling my hair out trying to get the ArduinoModbus working on ESP boards (M5Stack) and this works. The latest fix for the holding register size got me fully up and running.
The text was updated successfully, but these errors were encountered: