Type casting custom structs to BaseSequentialStream

ChibiOS public support forum for all topics not covered by a specific support forum.

Moderators: RoccoMarco, lbednarz, tfAteba

Post Reply
kopanz
Posts: 9
Joined: Mon Jan 26, 2015 10:40 pm

Type casting custom structs to BaseSequentialStream

Post by kopanz »

Hi,

I have seen an example on Github that are printing characters to a GLCD by chprintf(),

Code: Select all

chprintf((BaseSequentialStream *)&GLCDD1, "chTimeNow: %d", chTimeNow());

Like this.

I have read the source of GLCD driver and couldn't find any relation between BaseSequentialStream and GLCD driver.
Can you please explain this kind of type casting by your similar experiences.
https://github.com/miguelmoreto/ChibiOS-LCD-Driver/blob/master/glcd.c
https://github.com/miguelmoreto/ChibiOS-LCD-Driver/blob/master/demos/drawing/main.c
GLCD driver and main.c can be found here. You can have a look if you have some time :)

Thank you
User avatar
Giovanni
Site Admin
Posts: 14892
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: Type casting custom structs to BaseSequentialStream

Post by Giovanni »

Hi,

You should look into the header file where the GLCD structure is defined, there it is where the stream behavior is inherited.

Giovanni
kopanz
Posts: 9
Joined: Mon Jan 26, 2015 10:40 pm

Re: Type casting custom structs to BaseSequentialStream

Post by kopanz »

Giovanni wrote:Hi,

You should look into the header file where the GLCD structure is defined, there it is where the stream behavior is inherited.

Giovanni

It's not defined in the header file, but maybe it's not working.
Never mind Giovanni, Thanks :)
Post Reply