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

undefined identifier STREAM_UART

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



Joined: 22 Apr 2006
Posts: 87

View user's profile Send private message

undefined identifier STREAM_UART
PostPosted: Sat Aug 08, 2009 6:40 pm     Reply with quote

Hi can any one please tell me how to use the following code? I get an error when I compile it, undefined identifier STREAM_UART.
Code:

void pc_recv_check(void)
{
  char string1[80], string2[5];

  if (kbhit(STREAM_UART))
  {
    strcpy(string2, "fred"); //This will automatically add '\0' to the end of your string and is neater
    fgets(string1, STREAM_UART);
    if(strcmp(string1, string2) == 0) // strcmp returns 0 if they are equal!
    {
      fprintf(STREAM_UART, "Password_OK\r\n "); //Print ok if they match
    }
    else
    {
      fprintf(STREAM_UART, "Password_BAD\r\n "); // Print BAD if they dont match
    }
  }
}
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sat Aug 08, 2009 7:38 pm     Reply with quote

Make sure you have a #use rs232() statement that specifies that identifier
as the stream.
deltatech



Joined: 22 Apr 2006
Posts: 87

View user's profile Send private message

PostPosted: Sun Aug 09, 2009 6:07 am     Reply with quote

Hi PCM PROGRAMMER Thanks for your reply . Can you please give an example what you mean, or how to do it. Many thanks in advance.
deltatech



Joined: 22 Apr 2006
Posts: 87

View user's profile Send private message

PostPosted: Sun Aug 09, 2009 7:36 am     Reply with quote

I have managed to compile now, but I do not get anything on the Hyperterminal. Can anyone please tell me what I am doing wrong ? Many thanks

Code:

#include "L:\Program Files\PICC\Project\RF-RS232\streamuart.h"
#include <string.h>  // This at the top of your file somewhere !
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7, ERRORS, PARITY=E, BITS=7,STREAM=STREAM_UART)
#include <string.h>
void pc_recv_check(void);
void main()
{

pc_recv_check();
}


void pc_recv_check(void)
{
  char string1[80], string2[5];
  if (kbhit(STREAM_UART))
  {
    strcpy(string2, "fred"); //This will automatically add '\0' to the end of your string and is neater
    fgets(string1, STREAM_UART);
    if(strcmp(string1, string2) == 0) // strcmp returns 0 if they are equal!
    {
      fprintf(STREAM_UART, "Password_OK\r\n "); //Print ok if they match
    }
    else
    {
      fprintf(STREAM_UART, "Password_BAD\r\n "); // Print BAD if they dont match
    }
  }
}
Ttelmah
Guest







PostPosted: Sun Aug 09, 2009 12:22 pm     Reply with quote

You won't....

When the chip wakes up, will a character have been received?.
Without a received character, what will 'kbhit' return?.
Once this has been tested, your code then goes on, and runs 'off the end'. Will anything then be received?.

You need to _loop_ and wait for data.

Best Wishes
Guest








PostPosted: Sun Aug 09, 2009 9:35 pm     Reply with quote

I notice that BOTH of your possible transmit messages
add an extra space in a weird place - AFTER the \r\n.

Do you mean to do that ?
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