LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

how to save data from COM port to file?

Solved!
Go to solution

@CrackJack wrote:

so, my question is, is there a way though which I can mark an "end of data" stream byte or send such a byte in labview?

thanks,...


Why not just use a special control character of your choosing?  How about NULL (0x00)?

-----------------------------------------------------------------------------------------
Reese, (former CLAD, future CLD)

Some people call me the Space Cowboy!
Some call me the gangster of love.
Some people call me MoReese!
...I'm right here baby, right here, right here, right here at home
0 Kudos
Message 21 of 38
(1,653 Views)

there might be lot of times, when the data i am sending would contain NULL (0x00) value but i got your point, i can simply send a "End of Data Char" and keep on cheking in my uC if i get that..

Now on LabVIEW 10.0 on Win7
0 Kudos
Message 22 of 38
(1,651 Views)

If you are sending ASCII type of data, then using a special character such as a line feed (x0A) or a null (x00) is a good way to go.  If you are sending binary type of data where a byte could be any value, then you can't use a special character.  So the best way then is to setup up your messages so that the data is prepended with 1 or more bytes (always the same number) that reflects how many more bytes follow.  So you read a byte, let's say it is 32, then you keep reading until you receive 32 bytes.  If you want a full fledged protocol, you could also have special bytes that might be a start byte, end byte, a checksum, etc.  So a typical package of data might be Start byte, 2 bytes for number of bytes to follow, your data package, perhaps 2 bytes for CRC-16 checksum, then and ending byte.

Message 23 of 38
(1,646 Views)

@All, thanks for all the suggestion, i am almost to the end of my program.. except 1 last hindrance...

 

  • when i save the data byte by byte to a file as (Raven's Fan had suggestd in post 2), my entire labview vi just dies down... everything becomes very slow... why would this happen?

I chucked the idea of saving byte by byte and now writing the entire bytes as they come, but new problem is;

 

  • I am sending a '#' byte from my uC to mark the end of data transfer.. labview somehow doesn't understand the advent of single 1 byte '#' hence, doesn't recognize this end of data transfer... however, when i put break-points

in my uC code, and stop the code at the line no. where this '#' is being transferred from TXBUF and increment the program counter step-by-step, labview then understands this 1 '#' byte...

 

what could be happening?

 

Now on LabVIEW 10.0 on Win7
0 Kudos
Message 24 of 38
(1,629 Views)

Post this section of code that processes the # character in LV.

-----------------------------------------------------------------------------------------
Reese, (former CLAD, future CLD)

Some people call me the Space Cowboy!
Some call me the gangster of love.
Some people call me MoReese!
...I'm right here baby, right here, right here, right here at home
0 Kudos
Message 25 of 38
(1,622 Views)

hello, please check the attached file... the sequence "check if "#' character is sent by micro-controller to mark end of data stream" is connected to the STOP button of the while loop, which basically means

if labview finds #, the Match True/False String.vi will return a TRUE value, which could end the while loop (connected as STOP IF TRUE).

 

Now on LabVIEW 10.0 on Win7
0 Kudos
Message 26 of 38
(1,610 Views)

You are writing the entire string you receive to the file.  You are detecting whether the string contains a "#", but you aren't doing anything to break the string there to only write the portion of the string up to the "#".

0 Kudos
Message 27 of 38
(1,608 Views)

@Raven's Fan, i have connected the output of the Match True/False String.vi to the control logic of while loop, so that whenver '#' is detected, the Match True/False String.vi returns a true, which stops the entire labview program...  attached is the file...

did i answer your question, is this what you wanted to know??

Now on LabVIEW 10.0 on Win7
0 Kudos
Message 28 of 38
(1,600 Views)

No, RavensFan is talking about detecting the received string before the file write.  In other words, only write those characters you need to the file.  You don't need to write the '@' or '#' control characters.  Your detection code doesn't need to be in the sequence structure either.

-----------------------------------------------------------------------------------------
Reese, (former CLAD, future CLD)

Some people call me the Space Cowboy!
Some call me the gangster of love.
Some people call me MoReese!
...I'm right here baby, right here, right here, right here at home
0 Kudos
Message 29 of 38
(1,594 Views)

everyone, i solved that problem. but now have a new problem...

 

Labview gets hanged when i transfer more than 256 bytes from my uC to PC. does this have to be because of some internal buffer? because 2^8 = 256, so, i thought if this would be related to some internal buffers?? I want to transfer 1GB data from uC to PC.

Now on LabVIEW 10.0 on Win7
0 Kudos
Message 30 of 38
(1,575 Views)