Jump to content

Recommended Posts

Hope someone has been there with this one.

 

I am sending data thru an RF link.

Data sent is: 0F 0F 02 10 02 1E 50 04

Continuous stream is transmitted by PIC1 ( 16F873 ).

A 4800 baud link from the receiver PIC2 ( 16F884 ) is received perfectly on a PC.

 

Problem is ( using 'buffer[t] = getc()' ) data is now: 30 46 30 46 30 32 31 30 30 32 31 45 35 30 30 34

when using the native RS-232 routines. Naturally this is 1 character at a time.

 

Surely there is a function/routine to recover the data in the original format but perhaps

this is an uncommon problem.

 

ANY help is appreciated.

 

Carlos

Link to post
Share on other sites

Hi Carlos,

 

I can see nothing wrong with the data you are receiving. Your transmitter seems to be sending each character as 2 ascii hex nibbles. It is your job to recombine these nibble pairs back into the original data.

 

Cheers

 

Reynard

Link to post
Share on other sites
Hi Carlos,

 

I can see nothing wrong with the data you are receiving. Your transmitter seems to be sending each character as 2 ascii hex nibbles. It is your job to recombine these nibble pairs back into the original data.

 

Cheers

 

Reynard

 

Well hello....

 

I wonder if you read the entire post.

Your first line assumes to me that you did not read this:

>>A 4800 baud link from the receiver PIC2 ( 16F884 ) is received perfectly on a PC.

 

Your second sentence assumes to me that you did not read this:

>>Problem is ( using 'buffer[t] = getc()' ) data is now: 30 46 30 46 30 32 31 30 30 32 31 45 35 30 30 34

when using the native RS-232 routines. Naturally this is 1 character at a time.

 

Not any help

 

>>>>ANY help is appreciated.

 

Carlos

>>>>>

 

but thanks anyway...I hacked at it for a while and got it done.

Link to post
Share on other sites
  • 2 weeks later...

>>>>ANY help is appreciated.

 

Carlos

>>>>>

 

but thanks anyway...I hacked at it for a while and got it done.

 

Then....after looking at the hacked code my son explained

how to use buffers....

Now my RF link response is almost immediate since not having to wade thru my

hacked code.

 

Buffer is filled with 32 bytes of stream using getc().

RXBuffer is 5 bytes

Here is the code that converted the data back to integers:

 

RxBuffer[0] = buffer[t+4];

RxBuffer[1] = buffer[t+5];

RxBuffer[2] = buffer[t+6];

RxBuffer[3] = buffer[t+7];

RxBuffer[4] = 0;

J1Tmp = atoui_hex(RxBuffer); // Left joystick value 2 bytes (0 to 03FF)

RxBuffer[0] = buffer[t+8];

RxBuffer[1] = buffer[t+9];

RxBuffer[2] = buffer[t+10];

RxBuffer[3] = buffer[t+11];

RxBuffer[4] = 0;

J2Tmp = atoui_hex(RxBuffer);//Right joystick value 2 bytes (0 to 03FF)

 

I tried to use 'atoui' before on this but I was using the back end of the buffer instead of the front.

Naturally everything came out wrong. A little help from my son got me going. An' I understand buffers now, I hope!

 

Carlos

Link to post
Share on other sites

Join the conversation

You are posting as a guest. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...