added option to dump frame in HEX to stdout before writing it to the serial port

This commit is contained in:
Robert Johansson 2012-05-13 16:32:55 +09:00
parent 6f76632728
commit 59fca0a709

View File

@ -167,6 +167,16 @@ mbus_serial_send_frame(mbus_serial_handle *handle, mbus_frame *frame)
return -1;
}
#ifdef MBUS_SERIAL_DEBUG
// if debug, dump in HEX form to stdout what we write to the serial port
printf("%s: Dumping M-Bus frame [%d bytes]: ", __PRETTY_FUNCTION__, len);
for (i = 0; i < len; i++)
{
printf("%.2X ", buff[i]);
}
printf("\n");
#endif
if ((ret = write(handle->fd, buff, len)) != len)
{
fprintf(stderr, "%s: Failed to write frame to socket (ret = %d: %s)\n", __PRETTY_FUNCTION__, ret, strerror(errno));