Quality RTOS & Embedded Software

 Real time embedded FreeRTOS RSS feed 
Real time embedded FreeRTOS mailing list 
Quick Start Supported MCUs PDF Books Trace Tools Ecosystem TCP & FAT Training




Loading

Why does xSerialGetChar() in demo use 'signed char' type?

Posted by dbuntin on August 30, 2015

I've extended the serial.c and serial.h files from the demo application to facilitate writing strings and debug information to the serial console in my application. I'm using snprintf() and similar library functions defined in stdio.h. These functions use parameters of type " char * ". When passing strings created by these functions to xSerialPutChar() and xSerialPutString() a must cast to a " signed char * " to avoid compiler warnings. Before I make any changes, I'd like to fully understand the types used and the reasons behind them.

Why does xSerialPutChar() use a signed char in it's prototype?

signed portBASETYPE xSerialPutChar( xComPortHandle pxPort, signed char cOutChar, TickTypet xBlockTime );

I'm also not sure I understand the full meaning of the parameter type "const signed char * const pcString" used in xSerialPutString. Could someone help me interpret this type and the use of const twice?

void vSerialPutString( xComPortHandle pxPort, **const signed char * const **pcString, unsigned short usStringLength );

Background: I've created my application based on the AVRATMege323WinAVR demo applicaiton. I'm using AVR Studio and it's native GCC complier.

Thanks, David


Why does xSerialGetChar() in demo use 'signed char' type?

Posted by rtel on August 30, 2015

You are looking at quite an old file. For portability, the original coding standard did not allow unqualified char types (without the signed or unsigned qualifier) because some compilers default char types to signed and some to unsigned. That has since been relaxed to allow unqualified char types if the char is an ascii character or pointing to a string of ascii characters.

I'm also not sure I understand the full meaning of the parameter type "const signed char * const pcString"

That is a C question, easy to look up in any C reference book or on the web - we like to keep questions on the forum specific to FreeRTOS as it is more valuable to FreeRTOS users that way - there are plenty of general embedded programming forums [the answer in this case is that the type is a const pointer to a const string - neither the pointer, nor the string in points to, can be modified.]


Why does xSerialGetChar() in demo use 'signed char' type?

Posted by dbuntin on August 30, 2015

Thanks.

On the C question, I'll be more resourceful in the future.

David B.


[ Back to the top ]    [ About FreeRTOS ]    [ Sitemap ]    [ ]




Copyright (C) 2004-2010 Richard Barry. Copyright (C) 2010-2016 Real Time Engineers Ltd.
Any and all data, files, source code, html content and documentation included in the FreeRTOSTM distribution or available on this site are the exclusive property of Real Time Engineers Ltd.. See the files license.txt (included in the distribution) and this copyright notice for more information. FreeRTOSTM and FreeRTOS.orgTM are trade marks of Real Time Engineers Ltd.

Latest News:

FreeRTOS V9.0.0 is now available for download.


Free TCP/IP and file system demos for the RTOS


Sponsored Links

⇓ Now With No Code Size Limit! ⇓
⇑ Free Download Without Registering ⇑


FreeRTOS Partners

ARM Connected RTOS partner for all ARM microcontroller cores

Renesas Electronics Gold Alliance RTOS Partner.jpg

Microchip Premier RTOS Partner

RTOS partner of NXP for all NXP ARM microcontrollers

Atmel RTOS partner supporting ARM Cortex-M3 and AVR32 microcontrollers

STMicro RTOS partner supporting ARM7, ARM Cortex-M3, ARM Cortex-M4 and ARM Cortex-M0

Xilinx Microblaze and Zynq partner

Silicon Labs low power RTOS partner

Altera RTOS partner for Nios II and Cortex-A9 SoC

Freescale Alliance RTOS Member supporting ARM and ColdFire microcontrollers

Infineon ARM Cortex-M microcontrollers

Texas Instruments MCU Developer Network RTOS partner for ARM and MSP430 microcontrollers

Cypress RTOS partner supporting ARM Cortex-M3

Fujitsu RTOS partner supporting ARM Cortex-M3 and FM3

Microsemi (previously Actel) RTOS partner supporting ARM Cortex-M3

Atollic Partner

IAR Partner

Keil ARM Partner

Embedded Artists