Jump to content

Write binary to file


jro1952

Recommended Posts

Posted

Hola, necesito AYUDA, soy entusiasta de temas técnicos, autodidacta, jubilado, pero con la mente intentando hacer cosas nuevas para mi conocimiento. El asunto es asi: desde un arduino controlo una placa Esp32 Cam, a la cual le ordenó sacar una foto y enviármela al serial port, la cual recibo correctamente, con su encabezado EB91 (ADJUNTO ARCHIVO).

Genere un .vi con el cual pretendo primero, leer la trama, filtrar y guardar en un archivo binario con extensión. jpg. Aquí empieza mi problema; veo la trama correctamente filtrada pero no logro guardarla, a pesar de varios intentos.(Adjunto el vi).

Genere un .vi para guardar como texto y lo hace correctamente. (Adjunto el .vi y su trama adquirida).

Si alguien puede ayudarme será bienvenida su mano. Espero este claro el planteo. Gracias por su tiempo. Labview version 10, con windows vista, ya se del siglo pasado..bue es lo que hay...jajterminal.txtRECEPCIONFOTOTet.viterminalTrama.txtRECEPCIONFOTOBin.vi

Posted (edited)
On 9/3/2026 at 2:16 AM, jro1952 said:

Hola, necesito AYUDA, soy entusiasta de temas técnicos, autodidacta, jubilado, pero con la mente intentando hacer cosas nuevas para mi conocimiento. El asunto es asi: desde un arduino controlo una placa Esp32 Cam, a la cual le ordenó sacar una foto y enviármela al serial port, la cual recibo correctamente, con su encabezado EB91 (ADJUNTO ARCHIVO).

Genere un .vi con el cual pretendo primero, leer la trama, filtrar y guardar en un archivo binario con extensión. jpg. Aquí empieza mi problema; veo la trama correctamente filtrada pero no logro guardarla, a pesar de varios intentos.(Adjunto el vi).

Genere un .vi para guardar como texto y lo hace correctamente. (Adjunto el .vi y su trama adquirida).

Si alguien puede ayudarme será bienvenida su mano. Espero este claro el planteo. Gracias por su tiempo. Labview version 10, con windows vista, ya se del siglo pasado..bue es lo que hay...jajterminal.txtRECEPCIONFOTOTet.viterminalTrama.txtRECEPCIONFOTOBin.vi

I haven't looked at the VIs yet but could it be that you use the Write to Text File node and have not disabled the convert EOL option on it? If you want to write binary data, it is usually better to use the according Write to Binary File instead, but here you must not forget to wire a FALSE to the prepend array of string size input if the binary data is already the final format you need in the file.

Edited by Rolf Kalbermatter
Posted

Hola, gracias por su respuesta, el archivo de texto lo realice para verificar que los datos recibidos sean los correctos. Los datos que recibo es una foto, los envia la Esp32 via arduino, la intención es recibirlos, archivarlos en un file jpg y luego levantarlos y presentarlos en una solapa dedicada. Verificare sus indicaciones y me mantengo atento a su revisión de mis .Vi

Gracias por su atención 👍 

 

 

Posted (edited)

Shauns code is more robust than just scanning the lines. But you should NOT use Bytes at Serial Port ever (with a few very rare exceptions that you are unlikely to ever encounter)!

This is the default presentation that everybody should watch who is trying to implement serial port communication in LabVIEW: https://labviewwiki.org/wiki/VIWeek_2020/Proper_way_to_communicate_over_serial

Once you fixed the serial port communication, by using the termination character properly that you already enabled in the Serial Port Init by default, and simply removing the Byte at Port completely and instead wire a large number like 512 to the byte to read input, your main problem is this part of your code. 

image.png.df36d2e2cd97ae7bab3fdadd9b84bcf0.png

You should replace this with this part of Shaun's code:

image.png.b8056d0ef3e2caa08135ab14430bd281.png

Your code currently only converts the first two hex parameters of every received byte sequence and with your Bytes at Serial Port function you frequently won't receive an entire line, so only convert part of it. The remainder will be read in the next iteration but totally throw the Match Regular Expression function off the tracks as it does not see the expected line header.

 

Edited by Rolf Kalbermatter
Posted
1 hour ago, Rolf Kalbermatter said:

This is the default presentation that everybody should watch who is trying to implement serial port communication in LabVIEW: https://labviewwiki.org/wiki/VIWeek_2020/Proper_way_to_communicate_over_serial

Lots of exclamation points against using Bytes At Serial Port and then goes on to use Bytes At Serial Port :lol:

More seriously though. You avoid a lot of the problems if you just pop up on the read prototype and set it to Synchronous IO mode instead of Asynchronous.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.