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 support@ccsinfo.com

How to pass stream name of RS232 to a function?

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



Joined: 20 Jul 2011
Posts: 375

View user's profile Send private message

How to pass stream name of RS232 to a function?
PostPosted: Wed Apr 03, 2013 11:29 am     Reply with quote

Hi! I want to use 2 RS232 USART modules. So I set stream name for each one, but I don`t know how to pass the stream name to function, so I could use a single function for data transfer?
What is the datatype of stream? It`s not string!

I want to do this

Code:

void RS232Transmition(stream StreamName)
{
       if(kbhit(StreamName))
       {
             incomeData=getc(StreamName);
       }
}


Thanks!
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Wed Apr 03, 2013 12:53 pm     Reply with quote

Short answer: You can't pass a CCS "stream" identifier as a parameter.
You will have to use "if" statements and check a variable that you
define to hold the desired stream. Then, based on the value of that
variable, your "if" statement will call the desired fputc or fprintf
statement, etc., and use the desired stream.
RF_Developer



Joined: 07 Feb 2011
Posts: 839

View user's profile Send private message

PostPosted: Thu Apr 04, 2013 1:43 am     Reply with quote

PCM programmer wrote:
Short answer: You can't pass a CCS "stream" identifier as a parameter.


Reason: because getc() and similar IO functions are dealt with at compile time not runtime, so the parameters must be known - fully resolved - at compile time. Therefore you can't pass a variable to them at runtime.

RF Developer
Ttelmah



Joined: 11 Mar 2010
Posts: 19358

View user's profile Send private message

PostPosted: Thu Apr 04, 2013 7:20 am     Reply with quote

and of course 'behind' this is the core difference between writing code on the PIC, and something like a PC. On the latter you have hundreds of KB of 'OS' already loaded to do all these jobs. So simply changing which routine in the OS is called is simple. On the former, there is nothing outside your code, so the compiler has to generate the code to access a port when asked. Due to the lack of space, no more than is needed is loaded.....

Best Wishes
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