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

Selectable UART stream????

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







Selectable UART stream????
PostPosted: Mon Feb 25, 2008 2:07 pm     Reply with quote

I am using two UARTs in my application. Is there a way to be able to select between two rs232 streams without having to write another fprintf statement that does the same thing?

For example if my variable PORT=1 then I want to send the data out the first UART. If my variable PORT=2 then send data out the second UART

fprintf(PORT,"%d\r",data);


the compiler complains that the stream must be a constant. I'm just wondering if there is a way around this.

thanks
KD5UZZ_
Guest







Switch
PostPosted: Tue Feb 26, 2008 3:31 pm     Reply with quote

Code:

#use rs232(STREAM=PORT1,xmit=C6,rcv=C7,errors)
#use rs232(STREAM=PORT2,xmit=B2,rcv=B4)

int Port = 1;

switch (Port){
    case 1:
        printf(PORT1,"Blah blah blah");
        break;
    case 2:
        printf(PORT2,"Thing to print");
}



I doubt the #use rs232 lines are valid, but the rest of the code should work.
arunb



Joined: 08 Sep 2003
Posts: 492
Location: India

View user's profile Send private message Send e-mail

RE:
PostPosted: Sat Mar 01, 2008 4:41 am     Reply with quote

Hi,

The format for selecting from multiple streams is like this

Code:

#use rs232(STREAM=PORT1,xmit=C6,rcv=C7,errors)
void xmit_port1()
{
  printf("Blah blah blah");
}

//For the second stream...

#use rs232(STREAM=PORT2,xmit=C6,rcv=C7,errors)
void xmit_port2()
{
  printf("Thing to print");
}



thanks
arunb
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