How to get ASCII data in array.


Closed Thread
Results 1 to 9 of 9
  1. #1
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    3,796

    Default How to get ASCII data in array.

    Hi to all.

    I wonder if the modifier DEC can be used with STR in data array reception like this:

    Hserin [DEC3 STR array\n]

    I know the above won't compile, but as I am getting ascii data in 3 bytes packets, is there a special syntax that might do the trick?

    Thanks,
    Ioannis

  2. #2
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924

    Default

    Would something like this work?
    Code:
    [STR NUMS\16]	
    X1 = (NUMS[1]-"0")
    X2 = (NUMS[3]-"0")
    X3 = (NUMS[5]-"0")
    X4 = (NUMS[7]-"0")
    X5 = (NUMS[9]-"0")
    X6 = (NUMS[11]-"0")
    X7 = (NUMS[13]-"0")
    X8 = (NUMS[15]-"0")
    Dave
    Always wear safety glasses while programming.

  3. #3
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959

    Default

    Do the 3 bytes ever represent more than 255?
    If not, this might work ...
    Code:
    For LoopCount = 0 to n-1
        HSERIN [DEC3 array(LoopCount)]
    Next LoopCount
    But there's a distinct possibility of getting the wrong numbers if there's nothing between the 3 byte data packets.

    DT

  4. #4
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924

    Default

    Dave
    Always wear safety glasses while programming.

  5. #5
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    3,796

    Default

    Thanks boys.

    Currently, I do a simple 28bytes communication between radio modems using DT instant interrupts to get the Serial data like this:

    Code:
    Get_char:
       ser_in=0
          hserin 100,noreceived,[wait("##"),str temp_array\file]   'Get 28 characters
          if temp_array[0]=node then          'Are for this node station?
             ser_in=1	                    'if yes, then flag data and copy 
          endif
    noreceived:                         'else return
    @ INT_RETURN
    If data are coming to the serial port, then if the 2 first are ## data are captured in the temp_array (28 long)

    The first byte is the node station. If data are for this node, then a flag is raised.

    My concern is that, data can be any number including the $23 which is '#' character.

    So this might lead the routine to hang if data are out of sync sometime.

    My thought was to use data in the array only in ascii form without increasing length of temp_array x 3, by converting the ascii values while receiving them.

    Ioannis

  6. #6
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924

    Default

    Quote Originally Posted by Ioannis View Post
    My concern is that, data can be any number including the $23 which is '#' character.

    So this might lead the routine to hang if data are out of sync sometime.
    Why not use a TimeOut? Or can you not afford to miss any data?
    Dave
    Always wear safety glasses while programming.

  7. #7
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    3,796

    Default

    Please see the previous than yours post, that shows the timeout is there. But Darrel has explained very well why this might hang here:

    http://www.pbpgroup.com/modules/newb..._id=28&forum=8

    Ioannis

  8. #8
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924

    Default

    Quote Originally Posted by Ioannis View Post
    Please see the previous than yours post, that shows the timeout is there.
    OOPPS, I was sleepy?

    But Darrel has explained very well why this might hang here:

    http://www.pbpgroup.com/modules/newb..._id=28&forum=8

    Ioannis
    That was interesting, I now have it bookmarked.
    Just curios, is that the same project?
    Dave
    Always wear safety glasses while programming.

  9. #9
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    3,796

    Default

    No. That was an easy (now, for me...) project. It just transmitted the number in 3 bytes form. E.g. if number was 128 then the port would transmit ASCII '1', ASCII'2' and ASCII '3' or 49, 50 and 56 as decimal values.

    Ioannis

Similar Threads

  1. Using Nokia LCD
    By BobP in forum mel PIC BASIC Pro
    Replies: 300
    Last Post: - 3rd May 2018, 05:47
  2. Read/Write Problem
    By Tobias in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 10th February 2010, 02:51
  3. Big characters on HD44780 4x20
    By erpalma in forum mel PIC BASIC Pro
    Replies: 23
    Last Post: - 7th January 2007, 03:21
  4. LCD + bar graph
    By DynamoBen in forum mel PIC BASIC Pro
    Replies: 13
    Last Post: - 5th October 2005, 15:50
  5. Sinus calculating !
    By Don Mario in forum mel PIC BASIC Pro
    Replies: 29
    Last Post: - 29th November 2004, 00:56

Members who have read this thread : 1

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