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

Passing RS-232 streams

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



Joined: 27 Mar 2005
Posts: 30

View user's profile Send private message Visit poster's website

Passing RS-232 streams
PostPosted: Mon Feb 13, 2006 8:58 am     Reply with quote

I want to creat a function the will recieve some bytes and I am using two different rs232 streams. Both routines will be the same and I was wondering is any knew if it was possible to pass the stream identifier to my recieve function
Ttelmah
Guest







PostPosted: Mon Feb 13, 2006 10:19 am     Reply with quote

Yes, and no...
The code generated to handle a stream, is 'hardwired', to the I/O bit used. So you cannot use a variable to transfer it, and gain anything. The code has to exist seperately for each stream. However there is nothing to stop you from passing the name to a function, and then use a switch statement to select the required routine. The names can be passed as an int8 variable, so:
Code:

void fn(int8 chr,int8 stream) {
   switch (stream) {
   case hard :
      fputc(chr,hard);
      break;
   case soft :
      fputc(chr,soft);
      break;
   }
}   


With streams called 'hard', and 'soft', will allow you to send characters to a named stream.

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