CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

fprintf misunderstanding?

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
asmallri



Joined: 12 Aug 2004
Posts: 1635
Location: Perth, Australia

View user's profile Send private message Send e-mail Visit poster's website

fprintf misunderstanding?
PostPosted: Sun Feb 03, 2008 2:12 pm     Reply with quote

I am not sure if this is a bug or my misunderstanding. I am using 4.053

I have the following declarations

Code:

#use rs232(baud=115200,parity=N,xmit=PIN_C6,rcv=PIN_C7,bits=8)
#use rs232(baud=115200,parity=N,xmit=PIN_C6,rcv=PIN_C7,bits=8, STREAM=CONSOLE)
#use rs232(baud=2400,parity=N,xmit=PIN_G1,rcv=PIN_G2,bits=8, STREAM=DATA)


If I do this..
Code:

fprintf(DATA,"This is on the DATA port\r\n"); 
printf("This should be on the CONSOLE port\r\n)"


Both lines print on the DATA port. But if I do the following
Code:

fprintf(DATA,"This is on the DATA port\r\n"); 
fprintf(CONSOLE,"This is on the Console port\r\n");
printf("This should be on the CONSOLE port\r\n)"


Then the data message appears on the data port and the CONSOLE messages both appear on the console port. It appears the printf uses the output routines from the last STREAM.

Is this what is supposed to happen?
_________________
Regards, Andrew

http://www.brushelectronics.com/software
Home of Ethernet, SD card and Encrypted Serial Bootloaders for PICs!!
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sun Feb 03, 2008 2:50 pm     Reply with quote

Yes, I think so. If you use streams, everything should be a stream.
This includes the declarations and the print statements.
Ttelmah
Guest







PostPosted: Sun Feb 03, 2008 3:22 pm     Reply with quote

Historically, STDIO (which is what is used without a stream declaration), is always the _last_ #USE RS232 declaration the compiler has met. This is still true.

Best Wishes
asmallri



Joined: 12 Aug 2004
Posts: 1635
Location: Perth, Australia

View user's profile Send private message Send e-mail Visit poster's website

PostPosted: Sun Feb 03, 2008 3:27 pm     Reply with quote

In this case it is now broken. The stdio changes to whatever last fprintf stream was used.
_________________
Regards, Andrew

http://www.brushelectronics.com/software
Home of Ethernet, SD card and Encrypted Serial Bootloaders for PICs!!
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group