Decoding serial data bytes and nibbles.


Results 1 to 7 of 7

Threaded View

  1. #4
    Join Date
    May 2013
    Location
    australia
    Posts
    2,680


    Did you find this post helpful? Yes | No

    Default Re: Decoding serial data bytes and nibbles.

    neither of daves options works for me, I might be imagining the input differently
    I have a hex serial 15 byte data stream in a byte array.
    would need 30 bytes and could be parsed using serin2 ...[hex3 dw[0],hex3 dw[1] .......

    I assume a input constructed like this,

    ie 15 binary values in this order ,
    arraywrite inbuff ,[$ED,$1E,$D2,$EF,$2E,$D3,$ED,$2E,$D2,$EF,$2E,$D3,$E D,$1E,$D2]




    this does work



    Code:
      
      Pause 500       ' LCD initialize time
        lcdout $FE,1   
        inbuff var byte[15]
        
        dataword var word[10]
        d var byte
        INPOINTER VAR BYTE
        outpointer var byte
        arraywrite inbuff ,[$ED,$1E,$D2,$EF,$2E,$D3,$ED,$2E,$D2,$EF,$2E,$D3,$ED,$1E,$D2]
        
        
        for d=0 to 4
        dataword[d*2]=inbuff[d*3]*16+inbuff[d*3+1]>>4
        dataword[d*2+1]=inbuff[d*3+2]+(inbuff[d*3+1]&$f)*256
        next 
        
        for d=0 to 4
        IF D=4 THEN
        lcdout $FE,$80+d*4,hex3 dataword[d*2]
        lcdout $FE,$c0+d*4,hex3 dataword[d*2+1]
        ELSE
        lcdout $FE,$80+d*4,hex3 dataword[d*2],","
        lcdout $FE,$c0+d*4,hex3 dataword[d*2+1],","
        ENDIF
        next
    Attached Images Attached Images  
    Last edited by richard; - 18th January 2018 at 00:16.
    Warning I'm not a teacher

Similar Threads

  1. I need to play with Nibbles, am i on the right track?
    By OldMarty in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 5th July 2016, 13:32
  2. Replies: 7
    Last Post: - 11th September 2010, 00:32
  3. incorrect requested number of data bytes recieved
    By doxdlite in forum mel PIC BASIC
    Replies: 0
    Last Post: - 17th April 2010, 22:47
  4. Word to nibbles
    By Gauge Guy in forum mel PIC BASIC Pro
    Replies: 12
    Last Post: - 11th September 2005, 04:08
  5. Serial Data Recorder
    By d1camero in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 8th April 2005, 12:45

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts