Seperating data from garbage

Paul J.
Thousand Oaks, CA

Apr 17, 2015
16 Posts

0  |  0  

Re: Seperating data from garbage

Hi,

    I'm trying to read an RS232 port that spews out control codes and ASCII data, I need to parse out only the good data. How do you copy one element from an array to test it? Also, is there a more elegant way to test how much is in the receive buffer before reading it? OR should I be reading the port one byte at a time>

BAUD is 9600

loop
icount = ComReceive(LCD_PORT,"",100, ,byteArray)
if icount > 0  
    while i < icount
        byteOne = byteArray[i]        !!!!!!!! Here is part of the problem, How do you read one byte from an array?
        if ByteOne > 32   ! ASCII printable range
       if ByteOne <95  !range
           LCD_Data = LCD_Data + byteArray[i]    ! Save the good data
        endif
    i = i+1
    endwhile
endif
endloop

Thanks,
Paul

Paul T.
Maennedorf, Zurich

Apr 18, 2015
64 Posts

0  |  0  

Re: Seperating data from garbage

Hi Paul,


You can see your code below, with some adjustments made by me, if I understood you right.

Defining byteArray and LCD_Data as a unidimensional arrays with 10000 elements, for example. Do you have any idea how long the message could be? Do you need to acquire bytes in an infinite loop?

Redim byteArray[10000]
Redim LCD_Data[10000]

icount = ComReceive(LCD_PORT,"",100, ,byteArray)

if icount > 0
   Redim Preserve byteArray [icount]
   i=0
   k=0
    while i < icount
        byteOne = byteArray[i]        !!!!!!!! Here is part of the problem, How do you read one byte from an array?
        if ((byteOne > 32) /*ASCII printable range*/ and (byteOne <95)  /*range*/) then
           LCD_Data[k] = byteOne   ! Save the good data
           k = k+1
        endif
    i = i+1
    endwhile
Redim Preserve LCD_Data[k]  /*to limit the LCD_Data array only with the useful data*/
endif





Regards,
Paul T.

Paul J.
Thousand Oaks, CA

Apr 20, 2015
16 Posts

0  |  0  

Re: Seperating data from garbage

Hi Paul,

    Thanks for the help BUT the "byteOne = byteArray[i]" statement keeps incurring a "Cannot assign array to a non-array "ByteOne"" error.

    The array is a byte array and I am trying to copy one byte from that array to a single byte.

Thanks,
Paul

Victor B.
Lake Forest, CA

Apr 20, 2015
93 Posts

0  |  0  

Re: Seperating data from garbage

How is byteArray declared?

I'm thinking it's a 2-dimensional byte array, like Byte[1][1]

Paul T.
Maennedorf, Zurich

Apr 20, 2015
64 Posts

0  |  0  

Re: Seperating data from garbage

Hi Paul,

As Victor said: byteArray should be declared as Byte[1] and byteOne as a simple Byte. It should work without any problems.


Regards,
Paul T.

Paul J.
Thousand Oaks, CA

Apr 21, 2015
16 Posts

0  |  0  

Re: Seperating data from garbage

Its a simple one-dimensional 16 byte array. In a Procedure, I'm trying to copy one byte from the array to a byte variable (byteOne = byteArray[1]) Is the only way to a declare a variable in a procedure is to use the "Property" dialog box? You are limited to 19 bytes this way.

Paul J.
Thousand Oaks, CA

Apr 21, 2015
16 Posts

0  |  0  

Re: Seperating data from garbage

OH WOW...just figured it out!! "Dim" is referring to the dimension size of the array, not the the number of items in the dimension. Duhhhh.... thanks guys!!

Victor B.
Lake Forest, CA

Apr 21, 2015
93 Posts

0  |  0  

Re: Seperating data from garbage

When viewing a Procedure, local variables and parameters can be added/modified in the area above the code editor and below the procedure combo-box selector.  Right-click in this area and select 'Insert Parameter/Local Parameter'.  I attached an image.


File Attachment:
ExampleProcedure.png

Paul J.
Thousand Oaks, CA

Apr 22, 2015
16 Posts

0  |  0  

Re: Seperating data from garbage

Thanks for the information Victor.......

Victor, our ATE equipment uses COM1 thru 10 and COM 30, and 31. When I added a TTL-to-USB FTDI device to bypass our UUT LCD. It was assigned a COM of 11. I understand that ATEAsy won't read/write to COM devices over COM9 .....please say that isn't true!

Thanks,
Paul

Solution Available
Paul T.
Maennedorf, Zurich

Apr 22, 2015
64 Posts

1  |  0  

Re: Seperating data from garbage

That isn't true, Paul! ATEasy will work with COM Ports over 9 as well as other COM Ports...



Please Note
You need to have a M@GIC account to participate in the Forums.
Not yet registered on our website? Click here to register today!

All content, information and opinions presented on the Marvin Test Solutions User Forums are those of the authors of the posts and messages and not Marvin Test Solutions'. All attachments and files are downloaded at your own risk. [Read More]