LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

reading a text file into labview to interact with myrio

hello all so im sending data from my app that has push buttons to a text file and i want labview to read this text file. The text file will be in the following format.

 

08

0c

03........ etc.

 

 

and so on in hex, each number depends on which pushbutton are pressed there are 4 pushbutton so 16 different possibilites. When a pushbutton is pressed  it will correspond to the leds on the myrio so if i get the hex value 07 then led 0,1,2 will turn om, 08 hex led3 will turn on and so on. I have done the following to read the text file and use a for loop to read each line into a array. now i want to covert the hex value to binary format for the leds and also not sure which vis can read each number at a time correspond it the leds.

 

ble_data.png

 

Download All
0 Kudos
Message 1 of 10
(6,678 Views)

Hi muscles,

 

how do you save the text file?

What is the reason to use a FOR loop set to iterate just once?

Why do you read 100 lines at once?

You end up with a 2D array of numbers: when you want single elements you should use ArrayIndex…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 10
(6,675 Views)
You can check with number to Boolean array: https://zone.ni.com/reference/en-XX/help/371361M-01/glang/number_to_boolean_array/
Thanks
uday
0 Kudos
Message 3 of 10
(6,666 Views)
So actually I send the data from the pushbuttons over Bluetooth to a bleno server using JavaScript and from there I send the values to a text file.

I was using that for loop cause I figured that how you read lines in the test seemed like the solution and I created a text file with two numbers to test and I used 100 lines cause I don't know how many lines there will be because as long as I keep the app running and press the buttons different values will show up constantly.
0 Kudos
Message 4 of 10
(6,660 Views)

Hi muscles,

 

please attach a typical text file with our numbers…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 5 of 10
(6,626 Views)

Okay i attached the txt document and as you can see there are only a few lines but as i said the lines depend on how long im pressing the push buttons in my app. But they send hex values that should correspond to the leds on the myrio.

0 Kudos
Message 6 of 10
(6,610 Views)

Hi muscles,

 

it's as easy as this: check.png

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 7 of 10
(6,601 Views)

thank you cant believe it was that easy i guess i was over thinking it.

I have a problem though it doesnt seem to wanna work on the myrio leds or anything when i run it. When i press run all that happens is that the deploy box shows up dowloands and says it was a sucess and that it then the program stops.

 

Its works though when not using a myrio target vi.

 

Also when i use run example programs on the myrio to test it working they work but not my program.

 

See attached how i set upble_data.png


0 Kudos
Message 8 of 10
(6,596 Views)

Is the file actually on the myRIO?  You need to think of the myRIO as another computer.  Therefore it does not have access to your computer's harddrive.  You need to use WebDAV or FTP to put the file on your myRIO and then make sure the file control is looking in the right place.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 9 of 10
(6,591 Views)

Hi muscles,

 

says it was a sucess and that it then the program stops.

Basic LabVIEW knowledge: when a function provides an error output you should (have to!) check it.

You did not check the error output of the ReadText function. Please do so!

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 10 of 10
(6,589 Views)