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

serial port connection question ?

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



Joined: 08 Jan 2013
Posts: 14

View user's profile Send private message

serial port connection question ?
PostPosted: Tue Jan 08, 2013 12:35 pm     Reply with quote

please help :-(
what I want to do is below?
I will receive datas (data is like "t4y2o5v3") from XXX device with PIC16f877's serial port and then I will only get the numbers of this data (4253) and send them with serial port to YYY device. I did half of it. when you write with keypad t4y2o5v3 and press enter, I transmit 4253 to XXX device. but of course in real there is no keypad and enter key Smile there is YYY device produces datas like t4y2o5v3, t5y1o9v7 in 4800 baudrates. and what ı want to this I will get these t4y2o5v3, t5y1o9v7 datas in 4800 baudrates and send it is only numbers to XXX device... I am sharing to understand more open what I did, and what I want to do with photos below...

what I want to do?>


what I did? > http://b1301.hizliresim.com/15/8/hsdqg.jpg and;
http://a1301.hizliresim.com/15/8/hshs2.jpg
ezflyr



Joined: 25 Oct 2010
Posts: 1019
Location: Tewksbury, MA

View user's profile Send private message

PostPosted: Tue Jan 08, 2013 1:10 pm     Reply with quote

Hi,

Most likely this is an easy problem.

Does the data transmitted from 'XXX' always start with a 't' (lower case t),
and does it always end with a terminator (you call it 'Enter', is it really
carriage return <CR>? If so, inside your INT_RDA interrupt handler, look
for the 't' character, and start placing incoming characters into a buffer until
you receive the termination character. For each character received, test to
see if it is a digit (IsDigit() function) before storing. Once the termination
character is received, set a flag such as RcvString = True to tell your Main()
routine to send the parsed string out to YYY.

A couple of comments. Taking photos of your PC screen to show us the code
you have written is a terrible idea. Use the 'Code' buttons, and just post it! In
your code, your INT_RDA routine is really bad! Keep your interrupt handler
as short as possible, and never use printf inside the handler. At most, set
a global flag, and do all your time consuming steps in Main().

Good Luck!

John
bkamen



Joined: 07 Jan 2004
Posts: 1615
Location: Central Illinois, USA

View user's profile Send private message

PostPosted: Tue Jan 08, 2013 1:25 pm     Reply with quote

ezflyr wrote:

and does it always end with a terminator (you call it 'Enter', is it really
carriage return <CR>?



It could also be CR/LF (which is more common with DOS oriented platforms (sort of like Windows if the legacy aspect is considered..)


Just mentioning it...

And CR/LF is just as valid as LF/CR in terms of how a modern terminal will handle it... so be on the lookout.

-Ben
_________________
Dazed and confused? I don't think so. Just "plain lost" will do. :D
ckielstra



Joined: 18 Mar 2004
Posts: 3680
Location: The Netherlands

View user's profile Send private message

PostPosted: Tue Jan 08, 2013 1:53 pm     Reply with quote

Some general comments:
- #USE RS232, always add 'ERRORS' to this line so the compiler will clear error conditions for you.
- setup_spi(SPI_SS_DISABLED) is an invalid command to disable SPI. Change the parameter to FALSE.
- Why do you use the RDA interrupt? The way you have coded it now it is not how an interrupt should be written. Interrupts are short pieces of code where you get out of as quick as possible so the code in main() can continue.
- Instead of posting the code as an image it is much easier for us to read when you copy/paste it into your message. Use the 'Code' buttons to preserve the code layout.
- We don't like Proteus on this forum. There are to many bugs in it.

Note: I didn't do a page refresh before typing this reply and now see similar replies have been given already.
bkamen



Joined: 07 Jan 2004
Posts: 1615
Location: Central Illinois, USA

View user's profile Send private message

PostPosted: Tue Jan 08, 2013 2:00 pm     Reply with quote

I didn't look at the links.


NO PROTEUS.

TOO MANY BUGS!

See Sticky PIC101!!

http://www.ccsinfo.com/forum/viewtopic.php?t=47549

-Ben
_________________
Dazed and confused? I don't think so. Just "plain lost" will do. :D
hhuurrkkaann



Joined: 08 Jan 2013
Posts: 14

View user's profile Send private message

PostPosted: Tue Jan 08, 2013 2:32 pm     Reply with quote

Thanks for answers...

I didn't print screen them, took photos of screen because in the company which I am working, it is forbidden to take datas from computers...

ezflyr can you write the solution shortly that you prefer me in ccs c...

and yours question1: "Does the data transmitted from 'XXX' always start with a 't' (lower case t) " yes it always starts with "t".

question2: does it always end with a terminator (you call it 'Enter', is it really carriage return <CR>? datas is always receiving like below. It doesn't end with enter of course, I used enter key to see it in simulation. datas are always flowing with in 4800 baud like below...

t4y2o5v3
t1y3o9v6
t2y7o3v9
t3y4o9v4
.
.
.
.

thanks...
bkamen



Joined: 07 Jan 2004
Posts: 1615
Location: Central Illinois, USA

View user's profile Send private message

PostPosted: Tue Jan 08, 2013 3:11 pm     Reply with quote

hhuurrkkaann wrote:
Thanks for answers...

I didn't print screen them, took photos of screen because in the company which I am working, it is forbidden to take datas from computers...

ezflyr can you write the solution shortly that you prefer me in ccs c...



Am I hearing you correctly that you want EZflyer to write up a solution that you can use at work?

I don't think you're going to find anyone here willing to do your job for you.
_________________
Dazed and confused? I don't think so. Just "plain lost" will do. :D
Ttelmah



Joined: 11 Mar 2010
Posts: 19498

View user's profile Send private message

PostPosted: Tue Jan 08, 2013 3:13 pm     Reply with quote

A basic starting point:
Code:

char buffer[10];
int1 have_val=FALSE;
int8 ctr=0;

#INT_RDA
void rs232_rx(void) {
   char c;
   c=getc();
   if (c=='t') {
      if (ctr>0) {
         have_val=TRUE;
         buffer[ctr]='\0'; //terminate string
         ctr=0;
      }
   }
   else {
      if (c>='0' && c<='9') {
         buffer[ctr++]=c;
      }
   }
}

void main(void) {
    int16 depth=0;
    //your initialisation here

    enable_interrupts(INT_RDA);
    enable_interrupts(GLOBAL);
    do {
        if (have_val==TRUE) {
            have_val=FALSE;
            depth = atol(buffer);
            printf(lcd_putc("\f %ld",depth);
        }
    } while (TRUE);
}

Shows 'how', but you'll have to work out how to make it work.


Best Wishes
bkamen



Joined: 07 Jan 2004
Posts: 1615
Location: Central Illinois, USA

View user's profile Send private message

PostPosted: Tue Jan 08, 2013 3:16 pm     Reply with quote

Ttelmah wrote:
A basic starting point:
Shows 'how', but you'll have to work out how to make it work.

Best Wishes



You should have a proxy address for people to mail you gifts for your graciousness.

I'm sure Mrs. Field's cookies or ?? would be nice, no?

:D

-Ben
_________________
Dazed and confused? I don't think so. Just "plain lost" will do. :D
Ttelmah



Joined: 11 Mar 2010
Posts: 19498

View user's profile Send private message

PostPosted: Tue Jan 08, 2013 3:37 pm     Reply with quote

Thanks, Smile
The question now is whether he looks, understands, and 'pays any attention'?....
No Guarantee there are not typing errors.

It is a problem, because we have some threads where people will take a minor hint, while others need things served on a plate. He was missing a couple of really major points about what needs to happen, so it seemed worth taking the plunge and doing a basic version.

Wait for response at this point.....

Best Wishes
hhuurrkkaann



Joined: 08 Jan 2013
Posts: 14

View user's profile Send private message

PostPosted: Wed Jan 09, 2013 6:32 am     Reply with quote

bkamen wrote:
hhuurrkkaann wrote:
Thanks for answers...

I didn't print screen them, took photos of screen because in the company which I am working, it is forbidden to take datas from computers...

ezflyr can you write the solution shortly that you prefer me in ccs c...



Am I hearing you correctly that you want EZflyer to write up a solution that you can use at work?

I don't think you're going to find anyone here willing to do your job for you.



@ bkamen
here is an information sharing forum...
if u want to share information about questions you r useful for other people that asks you questions...but I guess your purpose is only spatchcock... so this makes u harmful...

I start to learn ccs c 2 weeks ago, and my questions can be foolish or easy for u, but if you feel that my questions are funny, dont answer me...thats all... already I didnt ask u to write the summery of the codes, I asked them to ezflyr... and Ttelmah shared starting of codes, so this is enough for me... I asked ezflyr for codes but then Ttelmah answered. So he didnt find my question about writing a part of the codes... and thanks a lot for your help Ttelmah.

in summery, if u wont help bkamen, please dont write anything.. in forums; sometimes writing anything makes people more useful...
Ttelmah



Joined: 11 Mar 2010
Posts: 19498

View user's profile Send private message

PostPosted: Wed Jan 09, 2013 7:18 am     Reply with quote

Seriously, that is a bad attitude.

Bkamen, is one of the long term 'good helpers' on the board. The point he was trying to make, is that you really started quite badly, by posting 'code pictures' (if you have to take pictures, then retype the code yourself), and not reading some of the basic things about the forum before starting....

I decided that on the basis of previous threads, it was likely to be completed with less annoyance all round, by actually showing the key big problems (which ckielstra had already pointed out), so would post some code, but I had similar doubts to him, and these have increased with your attitude.
ezflyr



Joined: 25 Oct 2010
Posts: 1019
Location: Tewksbury, MA

View user's profile Send private message

PostPosted: Wed Jan 09, 2013 7:34 am     Reply with quote

Hi hhuurrkkaann,

Sometimes we on the forum can seem a little bit harsh in our criticism, but
you need to consider it as "tough love". I've been around here for a few
years and I can honestly say that there are no mean-spirited members that
participate on a regular basis. Rather, there are a lot of guys that give up a
lot of their personal time to help new users like you. It's always a balance,
though, between providing too much help, and just enough to get a newbie
thinking on his own, and learning to use the compiler.

In the beginning I said this was a "simple" problem, but that is from the
perspective of an experienced user. Your project, for a beginner, is a bit
more advanced than I would generally recommend. Since you chose it, and
it's your project, the onus is on you to perform the "heavy lifting", not us!

Good Luck!

John
hhuurrkkaann



Joined: 08 Jan 2013
Posts: 14

View user's profile Send private message

PostPosted: Wed Jan 09, 2013 8:13 am     Reply with quote

thanks ezflyr

in fact I didnt write anything for your explanations. and of course you can find others questions easy or hard. I have no experience with ccs c, my experience is PLC and I shares my experiences to other people that asks me questions but I always talk about the issue that they asked to me, I never say that "I don't think you're going to find anyone here willing to do your job for you." Am I said "ezflyr can u do my job for me?" no! I only said that "ezflyr can you write the solution shortly that you prefer me in ccs c..." is this question so foolish or hard to write? I write lots of codes for help in my experienced business. here's purpose is sharing experience...already Ttelmah write the codes that he thinks to help my question. This was what I wanted, of course nobody dont have to write the codes for me. I only asked that if it is possible or not...
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