serial formatting


+ Reply to Thread
Results 1 to 5 of 5
  1. #1
    barkerben's Avatar
    barkerben Guest

    Default serial formatting

    Hi...


    As I understand it, I can use the serial formatting tags as follows:

    For instance, If I send the text string 123, consisting of 3 bytes coding for the characters 1,2,and 3, but specify

    HSERIN[DEC3 my_variable]

    Then I will receive those 3 bytes and they will be interpreted, then stored in the variable my_variable


    I have 2 questions about this:

    How much overhead is involved - it would seem to require an ASCII lookup on the pic to convert from character codes to actual values, and more jiggery pokery to combine them all into one number ...


    Also, what hapens if one of the characters sent is not a number - if, for instance, instead of sending 123 i send the string "abc", how will the code react ...?


    Cheers,


    Ben

  2. #2
    barkerben's Avatar
    barkerben Guest

    Default

    ...My other question is whether I can backfill with zeroes. For instance, if I specify DEC3, but in fact only want to sent 56, could I send the string 056 ...

  3. #3
    barkerben's Avatar
    barkerben Guest

    Default

    Ok - tests have shown that padding zeroes are ignored as hoped for

    For the moment I'm passing data as a string, but really want to pass raw bytes. If I have a word sized variable, then to fill it I need to receive 2 bytes. There seems to be no standard formatting command to achieve this. Is there some useful word.highbyte type syntax, or do I need to use the shift operators ....

  4. #4
    barkerben's Avatar
    barkerben Guest

    Default

    Ah - I've found the section in the manual:

    the answer is to use myvariable.byte1 and myvariable.byte2

    (or highbyte / lowbyte)

  5. #5
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898

    Talking

    As many says here, the best way to get answer to assumption is the real-life testing. then if you don't have the expected result after many different approach, looking in the FAQ, searching the forum thread, post question here with your whole code + PIC and everything we need to reproduce the problem. BUT i'm glad to see everything looks to work !!! Good luck!

    we still be there
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

Similar Threads

  1. Replies: 33
    Last Post: - 19th March 2010, 03:02
  2. Dynamic USB Serial Number (PIC18F4550)
    By awmt102 in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 16th July 2009, 17:03
  3. PIC18F4680 to PC via MAX232 (RS232 serial) no output
    By opticsteam1 in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 14th April 2008, 20:39
  4. interfacing to the pc serial port
    By kelangfei in forum General
    Replies: 4
    Last Post: - 7th October 2007, 22:35
  5. Serious Serial Situation Setbacks...
    By Dansdog in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 7th February 2007, 03:46

Posting Permissions

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