From 04:00 PM CDT – 08:00 PM CDT (09:00 PM UTC – 01:00 AM UTC) Tuesday, April 16, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Comunicación serial - Bandera de inicio y parada en paquete de datos

Buen día,

 

Me encuentro realizando una aplicación en Labview donde debo de leer por el puerto serial un paquete de bytes (el cual puede variar en su tamaño). Dicho paquete de bytes tiene un formato en el cual tengo un byte de inicio y de fin, anexo algo de información de dicho procedimiento.

 

Jorge1997_0-1636582106905.png

 

Mi problema es que no puedo usar la habilitación del carácter de terminación (modificado a 0x7E, para este caso) ya que solo recibo el byte de inicio los demas bytes no los procesa. Cada paquete lo voy agregando a un array

 

Por ejemplo, si yo espero leer el siguiente paquete de datos, 7E 7D 7D 7D 7D 7D 7E, solo veo el primer byte.

 

Jorge1997_1-1636582642176.png

 

Y si no tengo habilitado el caracter de terminación debido a que los datos que estoy leyendo los recibo muy rápido, tiende a concatenar varios paquetes, como en la siguiente imagen

 

Jorge1997_3-1636583704673.png

 

Lo que busco es lograr que en el array tenga los paquetes de esta manera.

 

Jorge1997_2-1636583615013.png

 

¿Existe alguna manera de poder configurar el puerto serie para poder filtrar estos paquetes de la manera que espero?

 

Espero haber explicado correctamente mi caso. Anexo el archivo del dispositivo con el que estoy trabajando. Prácticamente, lo correspondiente al procesamiento de los datos ya lo tengo, solo es este detalle que me esta deteniendo.

 

Saludos.

0 Kudos
Message 1 of 4
(723 Views)

The document states that the only occurence of 0x7E is at the start and end of a packet. I guess there is something amiss in how You read form the port. Could You share the .vi?

0 Kudos
Message 2 of 4
(684 Views)

I can attach a picture of the diagram block of the subvi.

 

Jorge1997_1-1636644292986.png

 

 

Jorge1997_0-1636644245134.png

 

In the Frames table, there are rows that the ID, Length and Data not contain info. This occurs because the array contain more that one package of data for this row in the table.

 

Thanks for your support.

0 Kudos
Message 3 of 4
(678 Views)

1. Turn OFF the termination character.  You are dealing with binary/hex/raw data.  And if one of those bytes just happens to match your termination character (default 0x0A), your read will end short of what you are trying to read.

 

2. DO NOT USE THE BYTES AT PORT!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! (still not enough emphasis)

You need to use the protocol to read your data to ensure you get a complete message and no more.  So I would attempt to read 1 byte until a 0x7E is read.  Then read enough bytes to get the ID and Length.  You can then use the Length to determine how many more bytes you need to read to complete the message, including any CRC or checksum.

 

You may want to watch this presentation: VIWeek 2020/Proper way to communicate over serial


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 4 of 4
(669 Views)