HRSIn Hex2 not working as expected


Today 20:07
Forum: Absolute Beginners Section
Starter: amod
Views: 0
Replies: 60
+ Reply to Thread
Results 1 to 4 of 4

Thread: HRSIn Hex2 not working as expected156 days old

  1. #1
    Junior Member mjturner's Avatar
    Join Date
    Dec 2003
    Posts
    88
    Thumbs Up
    Received: 14
    Given: 4
    Total Downloaded
    544.85 MB

    0 Not allowed!

    Default HRSIn Hex2 not working as expected

    I'm sending some data to a PIC over serial. The starting identifier is ":" followed by data in text as hex. For example ":020000040000FA" would be something i'm sending it.

    The following code:
    Code:
    ReceiveLine:
      Clear MessageBufferIndex
      Temp=HRSIn
      If Temp<>58 Then GoTo ReceiveLine
      MessageBufferPos=HRSIn Hex2
    Loops until it receives the ":", then should in theory try and read two bytes and convert them from Hex in to a byte value, based upon the description in the manual. However when I look at the value stored in MessageBufferPos I can see the value of 0x30, which is the ASCII value for "0". e.g. it appears to have read only the first byte after the ":" and given that as the result, without decoding it from Hex.

    I've no issue with coms over the serial port, it is happy sending and receiving data for other things. I don't want to just use the Hex directive, as I'm unclear how many bytes it'll try and read if I do that.

    Any thoughts?

  2. Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  3. #2
    Senior Member Mellbreak's Avatar
    Join Date
    Jun 2012
    Posts
    519
    Thumbs Up
    Received: 50
    Given: 23
    Total Downloaded
    3.16 GB

    0 Not allowed!

    Default Re: HRSIn Hex2 not working as expected

    Oops, sorry should have read your post more carefully.

    cheers,

    Bob
    Last edited by Mellbreak; 10th February 2019 at 15:25.

  4. Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  5. #3
    Fanatical Contributor top204's Avatar
    Join Date
    Feb 2002
    Posts
    3,247
    Thumbs Up
    Received: 375
    Given: 133
    Total Downloaded
    1.58 GB

    0 Not allowed!

    Default Re: HRSIn Hex2 not working as expected

    A serial modifier is not supported after the Hrsin command if it is used "inline". i.e. Var = Hrsin. See the manual's page 202.

    It has shown that I'm going to have to try and tighten the syntax checking of it, to monitor what is after the Hrsin text when it is used inline. This is because the Hrsin command can be used inside other command constructs, so it cannot simply block anything after it, so I'll trap any modifier texts after it and produce an error message. Thanks for pointing out this anomaly.

    I've just tested the code snippet below and it seems to work as expected:

    Code:
        Device = 18F25K20 
        Declare Xtal = 64
         
        Declare Hserial_Baud = 9600
        Declare Hserout_Pin = PORTC.6
        Declare Hserin_Pin = PORTC.7
        
        Dim Bytein As Byte
        Dim MessageBufferIndex As Byte
        Dim MessageBufferPos As Byte
        
        Do
    ReceiveLine:
            Clear MessageBufferIndex
            Bytein = HRSIn
            If Bytein <> ":" Then GoTo ReceiveLine        
            HRSIn Hex2 MessageBufferPos
            
            HRSOutLn "\rReceived: ", IHex2 MessageBufferPos   
        Loop
    You maybe could have used the Wait modifier for the colon:

    HRSIn Wait (":"), Hex2 MessageBufferPos

    Or a Repeat...Until loop instead of the If...Then, which does the same as the Wait modifier:

    Code:
        Clear MessageBufferIndex
        Repeat: Until HRSIn = ":"
    Last edited by top204; 10th February 2019 at 17:21.

  6. Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  7. #4
    Junior Member mjturner's Avatar
    Join Date
    Dec 2003
    Posts
    88
    Thumbs Up
    Received: 14
    Given: 4
    Total Downloaded
    544.85 MB

    0 Not allowed!

    Default Re: HRSIn Hex2 not working as expected

    Quote Originally Posted by Les View Post
    A serial modifier is not supported after the Hrsin command if it is used "inline". i.e. Var = Hrsin. See the manual's page 202. I'm going to have to try and tighten the syntax checking of it, to monitor what is after the Hrsin text when it is used inline.
    Ah that would explain it. I did scan for an example, but the lack of example meant I just saw the modifier details a few pages down without context of where to place it, and then I didn't scroll to the top of the section and see the modifier required this syntax.

    I'll give it a go, but I suspect it'll work

  8. Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

     

Similar Threads

  1. I2COut V 3.6.0.2/1.0.4.4 ERROR Value Expected
    By ChrisRowe in forum Proton 24
    Replies: 3
    Last Post: 29th August 2017, 11:13
  2. HPWM on a 18F1320, not as expected...
    By Eriond in forum Absolute Beginners Section
    Replies: 12
    Last Post: 6th June 2015, 10:36
  3. POW - result not as expected
    By chrisall in forum Proton Plus Compiler v3
    Replies: 14
    Last Post: 27th March 2008, 09:28
  4. Interrupts, not what I expected
    By oldman in forum Proton Plus Compiler v3
    Replies: 6
    Last Post: 10th February 2008, 21:10
  5. What are the expected features in a new IDE?
    By octal in forum Proton Plus Compiler v3
    Replies: 37
    Last Post: 7th December 2007, 12:20

Members who have read this thread since 6th July 2019, 12:54 : 0

Actions :  (Set Date)  (Clear Date)

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