11-10-2021 04:42 PM
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.
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.
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
Lo que busco es lograr que en el array tenga los paquetes de esta manera.
¿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.
11-11-2021 07:43 AM
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?
11-11-2021 09:26 AM - edited 11-11-2021 09:33 AM
I can attach a picture of the diagram block of the subvi.
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.
11-11-2021 10:35 AM
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