Forum - MCS Electronics

 

FAQFAQ SearchSearch RegisterRegister Log inLog in

Receiving 32 data bytes via UART without CR and LF - hex val

 
Post new topic   Reply to topic    www.mcselec.com Forum Index -> BASCOM-AVR
View previous topic :: View next topic  
Author Message
medicb

Bascom Member



Joined: 01 Aug 2009
Posts: 3

blank.gif
PostPosted: Wed Dec 06, 2017 2:32 am    Post subject: Receiving 32 data bytes via UART without CR and LF - hex val Reply with quote

Hi all 🙂 I need to receive packet 32 bytes of data from UART but there are not exist CR and LF on end of line. The transmit data are in one sequence without any breaks: 4 bytes of unchanging data, 12 data bytes (6 pairs of 2 bytes), 12 data bytes (6 pairs of 2 bytes), 2 bytes reserved data and 2 bytes checksum data. I can't operate on single bytes, I need to pair them. I should operate on hex values. I tried to use the WAITKEY command to wait for the first four characters and later INPUTBIN command for receive rest of data but the received data is not stable. The reading starts in random places and the data are received and converted into dec values - it's wrong for me. Example: if I have to receive "00" and "1C" I getting "0" (not "00") and "28". Second example: I should receive "01" and "23" and connect these two bytes into "0123" (hex) but I getting "0" and "35" (dec). Have no idea, please help me.

(BASCOM-AVR version : 2.0.7.8 )
Back to top
View user's profile
Tiny

Bascom Member



Joined: 10 Nov 2010
Posts: 89
Location: The Netherlands

netherlands.gif
PostPosted: Wed Dec 06, 2017 7:06 am    Post subject: Reply with quote

Hello,

are the 4 byte of unchanging data always the first 4 of the 32 bytes?

use the usart interrupt and capture the received byte into a 4 byte buffer (use fifo priciepe) and compare then in your main routine after the compare is oké.
buffer the the other 28 bytes.

regards Tiny
Back to top
View user's profile Visit poster's website
medicb

Bascom Member



Joined: 01 Aug 2009
Posts: 3

blank.gif
PostPosted: Wed Dec 06, 2017 8:31 am    Post subject: Reply with quote

Yes, the first 4 bytes are always the same.
424D001C0051009100A500350060006D37E010C903EC0064001C000E93000734
Back to top
View user's profile
Madf

Bascom Member



Joined: 13 Nov 2011
Posts: 169
Location: Moscow

russia.gif
PostPosted: Wed Dec 06, 2017 3:07 pm    Post subject: Reply with quote

If send:
Code:
Dim A as Dword
Printbin A


If receive:
Code:
Dim A as Dword
Inputbin A


Or use standart operator print with semicolon in end.
Code:
print A;
Back to top
View user's profile Visit poster's website
Duval JP

Bascom Member



Joined: 22 Jun 2004
Posts: 932
Location: France

france.gif
PostPosted: Wed Dec 06, 2017 5:31 pm    Post subject: Reply with quote

hi
you can
1) read the help file about ischarwaiting
2) if yes you fill an array of byte
3) you can manipulate it with a lot of command as

CHR(N)
CHARPOS
FORMAT
FUSING
INSTR
LCASE
LEFT
LEN
LTRIM
MID
RIGHT
RTRIM
SPACE
SPC
SPLIT
STR
STRING
TRIM
UCASE

Bon courage
JP
Back to top
View user's profile Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    www.mcselec.com Forum Index -> BASCOM-AVR All times are GMT + 1 Hour
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
You cannot attach files in this forum
You cannot download files in this forum