digidotcom / xbee_ansic_library

A collection of portable ANSI C code for communicating with Digi International's XBee wireless radio modules in API mode.
204 stars 116 forks source link

How do I define a VERBOSE macro when building? #39

Closed aylashiv closed 5 months ago

aylashiv commented 5 months ago

Hi, I 'm debugging the XBee remote_at code in common codes, where i have issued some console prints in Xbee_device.c file, but i'm unable to print the same. I'm using the xbee_dev_tick() function.

Thanks, Shiva.A###

tomlogic commented 5 months ago

You'll need to provide some more details. The xbee_device.c file refers to the local, serially-connected XBee module.

It sounds like you're using the remote_at sample program. Does that sample work as expected, when used with an unmodified xbee_device.c?

As for the failure, what are you expecting to see, and what are you seeing instead? Where are you adding console prints in xbee_device.c? What isn't printing?

Are you expecting fields of the xbee_dev_t structure to change?

aylashiv commented 5 months ago

Yes I'm using remote_at Sample common Program, the Sample Works expected wihout modifying the xbee_device.c File, I want to Enable XBEE_DEVICE_VERBOSE in xbee_device.c source file were i'm unable to do and want to have console prints in xbee_frame_dump_modem_status() function, I tried it, but unsuccesfull.

Thanks, Shiva.

tomlogic commented 5 months ago

I think you can just pass that macro definition to make, and have the C compiler use it.

make remote_at CFLAGS=-DXBEE_DEVICE_VERBOSE=1

Make passes CFLAGS to the C compiler, and it interprets the -D option to define the macro.

aylashiv commented 5 months ago

Passed the Above make command it shows a compile error of "unknown target" A screenshot attached. Screenshot from 2024-03-14 13-30-30 Thanks, Shiva.

tomlogic commented 5 months ago

You shouldn't have a platform.h in ports/posix. include/xbee/platform.h should automatically bring in ports/posix/platform_config.h. Try compiling with a fresh, unmodified repository.

aylashiv commented 5 months ago

Though I have the same un-modified also, it reflects this error, Attached the screenshot ports/posix/xbee_platform_posix.c:25:10: fatal error: xbee/platform.h: No such file or directory Screenshot from 2024-03-14 16-54-38

tomlogic commented 5 months ago

OK, defining CFLAGS on the command line overrides the setting inside the Makefile. My test compile passed because I didn't make clean beforehand.

Maybe the easiest solution is to edit the Makefile and add that macro to the DEFINE definition.

DEFINE = -DPOSIX -DXBEE_DEVICE_VERBOSE

Do a make clean and then make.

aylashiv commented 5 months ago

Its Working !!! Edited the Makefile for the above changes.

Thanks, Shiva.A

aylashiv commented 5 months ago

Hi, I have the issue still in having the custom prints in xbee_device.c file, which i'm unable to get it, that did not solved yet.

Thanks, Shiva.

tomlogic commented 5 months ago

It doesn't sound like it's an issue with this code, but with your attempts to have custom output from within xbee_device.c.

What is your expectation? What have you tried so far? You mention "custom prints". What do you want to print, and when do you want it to print?

aylashiv commented 5 months ago

I want to write the Xbee Mac address of the Xbee device attached locally to the machine to a file in my Machine

tomlogic commented 5 months ago

Let's move this to issue #40.