|
|
View previous topic :: View next topic |
Author |
Message |
Jason1980 Guest
|
Selectable UART stream???? |
Posted: Mon Feb 25, 2008 2:07 pm |
|
|
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 |
Posted: Tue Feb 26, 2008 3:31 pm |
|
|
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
|
RE: |
Posted: Sat Mar 01, 2008 4:41 am |
|
|
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 |
|
|
|
|
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
|