Skip to content

Introduce a new debugging function. #102

Open
wants to merge 1 commit into from

2 participants

@oldfaber
oldfaber commented Mar 7, 2013

PLEASE do not pull yet: this is a request for comments.

Problem:
If the modbus DLL is linked with a GUI application there is no stderr to write to.
It may be solved in the application, but it's not often done.

Solution:
Use the dbgprintf, that behaves differently under windows or other OSes.

Notes
* I removed the ctx->debug tests, I thing the speed gain they need is minimal,
and the new interface allows to dynamically select the verbosity level.
* I also had to replace perrors(), because the Windows socket functions DO NOT set
errno.

  • I only touched modbus-tcp.c, as a proof of concept.
  • The #define of the log level should probably go to a public header.
  • I only tested this code under Windows, it may not compile under Linux or other OSes.

Is this acceptable ?

Thank you.

@oldfaber
oldfaber commented May 8, 2013

Ehmm, libabc_private.h uses attribute, and that is not compatible with Microsoft C. My solution is already tested, and I have a branch of libmodbus fully converted if acceptable. For bonus points I aslo have lighly organized the packet dump functions. Anyway it's your call. Do you want to see my fully converted branch ?
Thanks
Fabio

@stephane
Owner

Yes could you share your branch?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.