Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

How to read and format its outout for a serial multi-line strings?

I'm writing a serial command to a microcontroller (DUT) and it takes 20 seconds (which are marked by 20 dots)

to respond back to the READ function buffer.

I have 5 conditional answers from which only 4 will be spitted out as follow:

 

a)     . . . . . . . . . . . . . . . . . . . .                                                                            (this is a time interval for the microprocessor do its job)

b)     Cal Results, 00.0degC,0000.00,0000.00,0000.00,0000.00,0000.00,0000.00        (ucontroller will provide these numbers)

c)     Calwarm pass gyro                                                                                        (ucontroller will provide this answer for a good DUT)

d)     Calwarm pass accel                                                                                       (ucontroller will provide this answer for a good DUT)

 

or

 

a)     . . . . . . . . . . . . . . . . . . . .                                                                            (this is a time interval for the microprocessor do its job)

b)     Cal Results, 00.0degC,0000.00,0000.00,0000.00,0000.00,0000.00,0000.00        (ucontroller will provide these numbers)

c)     Calwarm fail gyro bias outside valid range                                                        (ucontroller will provide this answer for a bad DUT)

d)     Calwarm fail accel bias outside valid range                                                       (ucontroller will provide this answer for a bad DUT)

 

Can someone help me to read the results by striping the multiline answered string from the READ buffer?

Is there any other better way to do it?

I need to display results on the front panel to visually tell the user also to save the results on a text file.

 

Anyone?

 

Thanks a million.

 

 

0 Kudos
Message 1 of 9
(4,621 Views)

Sorry all who read my question.

 

Here is the vi.............(I forgot to attached)

0 Kudos
Message 2 of 9
(4,604 Views)

That is certainly not a VI. Why did you post a hard to read image in some proprietary format instead of the actual code?

0 Kudos
Message 3 of 9
(4,602 Views)

Dennis,

 

Thanks for answering.  Attached find the code.

0 Kudos
Message 4 of 9
(4,596 Views)

at least two subvi's are missing and this is not a program but a big sequenceframe.

please try to modularize your code.

You are flushing all eventual returns from the instrument and writing only waiting fixed times.

one possibility would be to have a subroutine that flushes, waits and writes a string.

with correct error in/out you don't need a sequenceframe anymore.

 

If the only problem is to read the multiline string I need to see the initialise port subroutine that is missing and

greetings from the Netherlands
0 Kudos
Message 5 of 9
(4,590 Views)

Albert,

 

 

Attached find the missing vi's. If you can modify your way without changing the sequence of the commands

I'll try myself with the actual DUT (device under test).

All 3 temperature cases will have almost the same code but the commands.

Thanks for your suggestions.

0 Kudos
Message 6 of 9
(4,583 Views)

I cleaned a bit and saw also a lot of unused code!

take a look at the eventstructure and queued message handlers.

this makes it an awfull lot easier to see what you are doing

greetings from the Netherlands
0 Kudos
Message 7 of 9
(4,578 Views)

Albert,

 

The vi is more organize now but still the same problem.

Attached I'm sending you a print out of the hyperterminal resultant file,

It is what I'm expecting for response from this vi.

(sorry for the writings on the print out)

Thanks again.

0 Kudos
Message 8 of 9
(4,568 Views)

Indeed the same problem, because I only reorganised to make clearer what happened.

I did not change the working of the code.

One of the things you can do is look at what you get back.

Only one line is interesting, the rest could be used as a check, that the instrument is still living.

The interesting line starts with  "Cal Results, 00.0degC," including the comma at the end. But I doubt that it allways is 00.0degC, most of the time it should be a bit warmer...

But still  "Cal Results," could be a good identifier of the correct line.

Use the  Match Pattern  function in the string palette to find out that that is the line and then use Spreasheet String to array on the last part of the string to get the numbers separated.

just try on that string and build a subvi that researches this string and yes or no retuns a result.

If you don't succeed send your subvi in again.

Programming is trying and thinking and making parts work correctly to get a real program.

For a moment just try to unerstand how to translate strings coming from your microcontroller.

Each line returns either information (in the form of an array of numbers) or no numbers at all, but a status.

So the ruturn should be an array of doubles and a status. A status could be an enum with cold/warm/data any name can be given.

 

greetings from the Netherlands
0 Kudos
Message 9 of 9
(4,557 Views)