Losing data when extracting bytes from words - 16F18855


+ Reply to Thread
Results 1 to 26 of 26

Hybrid View

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


    Did you find this post helpful? Yes | No

    Default Re: Losing data when extracting bytes from words - 16F18855

    Yup, now confirmed. It's faster to use aliases than Richard's module strcpy.
    while totally ignoring the reasons why i do it that way

    1, you get every opportunity to vet the data before committing to overwrite the old data
    its east to vet whether by crc or any other test you can devise
    2, it can receive data from multiple devices and allow you to steer the data into appropriate structures at will

    if you really need speed without verification
    hserin 50,mainloop,[ wait("[",21), STR MsgData \21]


    you don't need any of that alias typing exercise
    Warning I'm not a teacher

  2. #2
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    3,170


    Did you find this post helpful? Yes | No

    Default Re: Losing data when extracting bytes from words - 16F18855

    Quote Originally Posted by richard View Post
    while totally ignoring the reasons why i do it that way

    1, you get every opportunity to vet the data before committing to overwrite the old data...

    Ah, so now I understand why you referred to the first field in Incoming[0] before the strcpy. I was wondering why you did that.


    Aliases are nice because I can give the elements a meaningful name instead of MsgData[x], and I don't have to move fields about.


    I won't be moving 80 bytes anyways. This was just a test to use your module along with all those characters on my LCD.

    I'll probably have a short layout, so I can "most likely" still use your module as you intended:

    1 byte, destination PIC ID (%11xxxxxx)
    1 byte, field ID (%1xxxxxxx)
    1 word, field value
    1 byte, return code
    1 word, CRC (just sum of 5 bytes)

    (return code might even be placed in the field value on reply and use only 4 bytes)


    At least now I know that I can slide 3 slide pots at the same time as fast as I can and not lose data, even if the ADC increments grow larger (I wasn't sure before these ADCin tests). The real test will be making sure it reaches MSFS properly via USB - that's where I worry. I know USB can pile up messages in a queue, I just don't want to have to do that in my programs as well.

    I still have to see if I can turn 2 encoders quickly at the same time to simulate a pilot and copilot each turning encoders. I want to make sure two people can share the panels, like when one changes radio frequency while the other changes heading.

    The harder part will be flying the same plane over LAN or internet. Having two sets of my panels being used at the same time is an unknown for now (the game supports shared cockpit).
    Last edited by Demon; - 20th March 2025 at 04:41.
    My Creality Ender 3 S1 Plus is a giant paperweight that can't even be used as a boat anchor, cause I'd be fined for polluting our waterways with electronic devices.

    Not as dumb as yesterday, but stupider than tomorrow!

Similar Threads

  1. Decoding serial data bytes and nibbles.
    By retepsnikrep in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 18th January 2018, 08:22
  2. Bits, Bytes Words and Arrays
    By Melanie in forum FAQ - Frequently Asked Questions
    Replies: 24
    Last Post: - 14th June 2016, 07:55
  3. ORing / ANDing bytes or words
    By mmargolis in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 19th March 2011, 20:12
  4. Success! Are they 'words' or are they 'bytes'?
    By BitHead in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 27th December 2009, 16:54
  5. Codespace Saving Tip... Don't mix Words and Bytes
    By Melanie in forum Code Examples
    Replies: 0
    Last Post: - 18th June 2004, 10:23

Members who have read this thread : 14

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