LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Sending files to serial port

Hi,

 

I need to send phyton files to my modem.

 

My VI works fine with files sizes under 6000bytes, but anything above does not work.

 

I open the file, read as binary, and simply send this using VISA SEND. Followed by Ready Bytes at port, and VISA Read.

 

 

I get this idea that I should break down the data into chunks and send it down the port when file size is larger than 6k bytes ?

 

Anyone have any experience in this?

 

Thanks

Goose

 

LV 8.6

 

 

0 Kudos
Message 1 of 14
(4,419 Views)

What do you mean "doesn't work", can you be more specific? 

Putnam
Certified LabVIEW Developer

Senior Test Engineer North Shore Technology, Inc.
Currently using LV 2012-LabVIEW 2018, RT8.5


LabVIEW Champion



0 Kudos
Message 2 of 14
(4,413 Views)

When Sending files up to 6k, I get OK reply from the modem.

But when sending above 6k, I get error.

 

I've tried changing the buffer size, but this had no effect.

0 Kudos
Message 3 of 14
(4,411 Views)
Can you show us the code you are using?
0 Kudos
Message 4 of 14
(4,391 Views)
In addition to this can you specify what error you are getting? This could go a long way towards helping you. In the mean time I attached some code that reads large files in chunks and sends the data via a VISA connection.


Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
0 Kudos
Message 5 of 14
(4,372 Views)

It looks like the problem i have is that the data is sent to the port as a string ?

 

The type of file I am sending is a object file, and perhaps converting this into a string changes some of the characters?

Should I use something like an u32 array?

 

Example of file contents below :

 

™N
ìÔ¸Jc       s{  k  Z  k Z k Z k l k Z k Z k Z k Z k     Z     d  f  d „  ƒ  YZ
 d e
 f d „  ƒ  YZ d f  d „  ƒ  YZ d e f d „  ƒ  YZ
 d e f d     „  ƒ  YZ d
 e f d „  ƒ  YZ d e f d
 „  ƒ  YZ d e f d „  ƒ  YZ d e f d „  ƒ  YZ d e f d „  ƒ  YZ d e f d „  ƒ  YZ d e f d „  ƒ  YZ d e f d „  ƒ  YZ d Z d e f d „  ƒ  YZ d e f d „  ƒ  YZ h  e ƒ  d <e ƒ  d  <e ƒ  d! <e ƒ  d" <e ƒ  d# <e ƒ  d$ <e
 ƒ  d% <e ƒ  d& <e ƒ  d' <e ƒ  d( <e d) e ƒ d* <e d+ e ƒ d, <e ƒ  d- <e ƒ  d. <Z e

0 Kudos
Message 6 of 14
(4,352 Views)

You shouldn't convert an object file to string, and you should not use a U32 array.  (Did you mean flatten to string?)

 

Have you done a search to see how others have implemented this?

Message Edited by Ray.R on 10-20-2009 08:02 AM
0 Kudos
Message 7 of 14
(4,339 Views)

Have a look at the following link, which has an example written in LV7.1: 

 

http://forums.ni.com/ni/board/message?board.id=170&message.id=147606

 

Unfortunately, I do not have LV installed on this PC and could not verify thecontent of the VI.  Also, I could not prepare a short example.. 😞

Message 8 of 14
(4,334 Views)

I posted a follow-up to your question in the other thread. I recommend that you use this thread to resolve your problem. It is much harder if you are using multiple threads to resolve your problem.

 

A basic copy of my response in the other thread:

What error are you getting? This simple piece of information is crucial in being able to give advice to resolve your problem. I suspect that you are simply timing out on your data transfer. Either you are not giving the receiver enough time to receive the data or you are not allowing enough time for the response. However, without more specifics it will be impossible to give you better advice.

Message Edited by Mark Yedinak on 10-20-2009 10:40 AM


Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
0 Kudos
Message 9 of 14
(4,314 Views)

Hi, sorry about the mixed threads...got a bit carried away.

 

Ok, so you've seen my send loop. And as I said, this works 100%, but on bigger files, it does not.

 

Sending a small file (up to 6k bytes), the modem immediately replies with OK if successfull (I've got a looped delay code which waits until bytes is received at the port before reading it)

 

Sending a larger file, once sending is completed, I read the port, and the ERROR is received. 

 

I've matched the bytes send output from VISA Send with the file size, and that is identical, so all bytes seems to be transmitted.

 

Why I get an Error reply I have no idea, I can only suspect port buffers or perhaps something like escape characters being sent down incorrectly - but then again, this is not a problem with small files.

 

desperate

0 Kudos
Message 10 of 14
(4,302 Views)