LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Read from RS232 problems

Hi

 

I try read an protocol from RS232, but appear an error when I use "scan from string"..

 

I have an PIC18F who put on serial port "fprintf(outport,"* 13:53:03 * N * 2323.453 * W * 3542.092 * 12 * 33 * 29 \n");"

 

on my VI I need separete all parameters.

 

someone can help me to see the problem?

 

best regards

0 Kudos
Message 1 of 21
(2,785 Views)

I do not think your error is in Scan from String. When I put the string you posted in, it returns all the values and no error. 

 

Most likely the problem is the use of Bytes at Port. Since the PIC is sending a termination character (\n), just set the byte count input to VISA Read to a  value larger than the number of characters you expect and let the Read wait for the \n.  Then you get a complete message (except possibly on the first iteration) and the decoding should work OK.

 

Lynn

0 Kudos
Message 2 of 21
(2,783 Views)

Hi

 

thanks

 

what ou make for don't have errors?

 

if a make may constante "0", have problems, if I put "1" or "2", continue with problems...

 

the is the easy way to solve my problem? (put my protocol, in diferentes windows)

 

"scan Strins" is the only wait who I now to make this...

 

somone can help mt?


best regards

0 Kudos
Message 3 of 21
(2,777 Views)

It looks like you have 57 characters in the string you posted. Try setting byte count to 100 or 200.

 

Lynn

 

200 bytes.png

0 Kudos
Message 4 of 21
(2,767 Views)

An array from spreadsheet string with '*' as separator should get you an array of the parameters (though the 1st one will be empty as you start off with a star)

/Y

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 5 of 21
(2,749 Views)

Hi

 

problem continue...

 

http://imageshack.us/a/img11/4513/usk5.jpg

now appear new error. :S

 

 

0 Kudos
Message 6 of 21
(2,725 Views)

Lynn,

Take another look at that PIC output

the last two chars are "\n" thats NOT an ascii escaped newline


"Should be" isn't "Is" -Jay
0 Kudos
Message 7 of 21
(2,719 Views)

Hi

 

I program with CCS, and output printf is:

 

"  fprintf(outport,"* %s * %s * %s * %s * %s * %s * %s * %lu\n",time, PNS, lat, PEW, longi, speed, alt, temperatura);"

 

I have "\n" on final...

Message 8 of 21
(2,715 Views)

Let's take this one step at a time. Does your PIC transmit a Line Feed character at the end of each transmission? Or is it literally sending a backslash character followed by a lower case n?

 

Lynn

0 Kudos
Message 9 of 21
(2,702 Views)

Hi

 

I don't understand your questions johnsold...

 

my PIC put on serial port this string every 1second

 

sometimes it work... but after a few second program crash and when crash, on window "dados do circuito", don't start on 1º parameter...

 

if I only read string, when I receive an char like "#" ou an letter, I forced the program to read correct string, I think (with this I change my printf to have this 1º char before the "*")

 

best regards

0 Kudos
Message 10 of 21
(2,691 Views)