49 views
in System Integration by

Hello,

I am successfully running a modified version of the device integration example for Raspberry Pi 3B+ and in the DeviceDriver.c file I have added some code which I want to get console outputs to my SSH terminal on the variable values.

I can see any hardcoded message using either printf or EwPrint but when i try to print the value of any variable (char in my example below) the program halts and a segmentation fault is reported in the console output.

Example code inserted into the DeviceDriver_ProcessData function:

		printf("Read\n");
		ID = frame.can_id;
		if (ID > 0) 
		{ 
			char B = '5';
			EwPrint(B); 
		} 
		else 
		{ 
			EwPrint("no message ID\n"); 
		}

Console output:

From the above code I would be expecting the program not to halt and the console to display:

Read

5

Can anyone help with getting variable contents onto the console from a devicedriver C file?

 

1 Answer

0 votes
by
 
Best answer

Hello,

it seems that you did not use EwPrint() or printf() correctly. The first parameter expects a pointer to the format string and not a single character - please see the declaration of these functions.

Please try

char B = '5';
printf( "%c\n", B );

Does it work?

Best regards,

Manfred

by
DOH! Yes thats it, sorry for the silly question it all works now.

Thanks very much for the help.

Kind regards,

ARC

Embedded Wizard Website | Privacy Policy | Imprint

...