RS232 receive an array (packet)


Closed Thread
Results 1 to 3 of 3

Hybrid View

  1. #1


    Did you find this post helpful? Yes | No

    Default Here is a start

    A var byte
    Message var byte[23]

    GetPacket:
    'Find start of packet
    SERIN Pin,Mode,Timeout,Label, A
    if A<> $C8 then GetPacket
    'Keep looking until we find $C8

    'Now get the 23 data bytes
    for a = 1 to 23
    SERIN Pin,Mode,Timeout,Label, message[A]
    next A

    'At this point you have an array of 23 bytes
    'Message[1] is the function to be executed
    'Message[2 - 23] are the PWM values

    Your code goes here

    goto GetPacket

    You will need to do some work to find which serial input mode supports 38,400 bps, MSB first or LSB first, number of stop bits, etc.
    There are alternative commands using WAIT (myvar) that can reduce the code above but the function is essentially the same.

    HTH
    BrianT
    Last edited by BrianT; - 12th February 2008 at 02:27. Reason: clarity

Similar Threads

  1. Bits, Bytes Words and Arrays
    By Melanie in forum FAQ - Frequently Asked Questions
    Replies: 24
    Last Post: - 14th June 2016, 07:55
  2. Simple Array Demo
    By Archangel in forum Code Examples
    Replies: 5
    Last Post: - 15th February 2010, 04:46
  3. WRITECODE stores wrong 14-bit word values in FlashMEM
    By BobPigford in forum mel PIC BASIC Pro
    Replies: 18
    Last Post: - 26th June 2009, 04:35
  4. Receiving Packet Array In Usart
    By crhomberg in forum mel PIC BASIC Pro
    Replies: 29
    Last Post: - 24th April 2007, 20:41
  5. Receiving Packet Array In Usart
    By crhomberg in forum Serial
    Replies: 1
    Last Post: - 18th April 2007, 22:31

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