LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Read non displayable characters from PC keyboard and send it to serial port.

Dear All,
I need to read non displayable characters ( Delete key, Left arrow key and Right arrow key) from PC key board using LabVIEW 8.0.
These characters won't get displayed, even if I am using String control with '\' Code Display.
After reading these characters, need to be sent to RS 232 port.
 
How can I read these characters using LabVIEW 8.0?
How to these characters to Serial Port?
Please suggest.
 
Regards
 
SajK
 
 
0 Kudos
Message 1 of 12
(4,427 Views)

You can detect which buttons were clicked by using the Key Down event in an event structure, but I believe you'll run into a problem - as far as I know, there are no ASCII characters for those buttons, so they're not non-displayable characters. If you're using another program to send commands through the serial port and you're using those buttons to simulate some characters, you will have to find out what those characters are. You can do this, for example, by going through the documentation for the program or by using programs like Portmon or by seeing if you copy the created string into LabVIEW.

Once you know what the characters you need are, you can add them to your string by using the Byte Array to String function, which takes an array of ASCII characters and turns it into a string. If you managed to copy the string mentioned earlier, you can use the reverse function to find out what the ASCII characters you need are.

To learn more about LabVIEW (and specifically the event structure), I suggest you try searching this site and google for LabVIEW tutorials. Here and here are a couple you can start with and here are some tutorial videos. You can also contact your local NI office and join one of their courses.
In addition, I suggest you read the LabVIEW style guide and the LabVIEW user manual (Help>>Search the LabVIEW Bookshelf).


___________________
Try to take over the world!
Message 2 of 12
(4,421 Views)
Hello SajK,

I don't have LabVIEW 8, only 7.1.1, but I would use this (attached VI) to detect keystrokes.

I don't really understand waht char you want to send (e.g. what char correspond to left arrow key...). Is it not a character define in the device's documentation that you should send ?

Hope this helps...

We have two ears and one mouth so that we can listen twice as much as we speak.

Epictetus

Antoine Chalons

Message 3 of 12
(4,420 Views)
Thanks for the reply .
Presently I am using Hyperterminal for this application.
This is used for menu selection in a LCD connected by RS232.
How to convert Scan code into ASCII ?
 
Regards
SajK
0 Kudos
Message 4 of 12
(4,403 Views)
Thank U TiTou,
I can find the scan code using your program.
How to convet this to a serial write string?
Any direct coversion method?
 
SajK
 
0 Kudos
Message 5 of 12
(4,403 Views)
What string (or command) do you send when you are using the hyper-terminal ?

I don't know the data format expected by you device... is it just the numeric code given by "scan code" tranformed into an ASCII string ?
This should be explained in the device's documentation, no ?

You have many function in LabVIEW that scan a number into string.

We have two ears and one mouth so that we can listen twice as much as we speak.

Epictetus

Antoine Chalons

0 Kudos
Message 6 of 12
(4,400 Views)
Thanks all.
I could find a solution.
Found the characters send to the external device on pressing Left and right arrow keys from Hyper terminal by tracing the firmware.
It is working fine.
 
Here  I am using Initalize Keyboard.vi and Acquire Input Data.vi together to read key board(LabVIEW 8.0). Is it ok?
Key press event  I cannot use because of someother problems..
 
Regards
sajK
Message 7 of 12
(4,380 Views)
Ok SajK,

I'm glad you found a suitable solution by yourself Smiley Happy

And thanks for the feedback, it is always intersting to know how people solve their problem Smiley Wink




We have two ears and one mouth so that we can listen twice as much as we speak.

Epictetus

Antoine Chalons

0 Kudos
Message 8 of 12
(4,370 Views)


@i wrote:
 
Here  I am using Initalize Keyboard.vi and Acquire Input Data.vi together to read key board(LabVIEW 8.0). Is it ok?
Key press event  I cannot use because of someother problems..
You can definitely use the input VIs to read the keyboard state, but in general, the event structure is preferable and I think the only cases in which the input VIs are necessary are if you want to capture the clicks even when your program doesn't have focus and when you want to detect clicks on more than one key (not including modifiers). Which problems do you have with events?

___________________
Try to take over the world!
Message 9 of 12
(4,361 Views)

Hi tst,

I need to change a lot of code  in my existing program to implement in that way. That is why.

I  need perform some actions as long as the key is pressed.Say, if Left arrow key is keep pressing, i need to keep sending a particular char to a External device.

Also key focus is given to Buttons, which are already handled by event cases.

Regards

SajK

 

**************************

tst wrote:

You can definitely use the input VIs to read the keyboard state, but in general, the event structure is preferable and I think the only cases in which the input VIs are necessary are if you want to capture the clicks even when your program doesn't have focus and when you want to detect clicks on more than one key (not including modifiers). Which problems do you have with events?

*************************

0 Kudos
Message 10 of 12
(4,338 Views)