how to access the keyboard ps/2 port directly?

S

skam

hi
i need to send an HEX String to the ps/2 port.
i have a special keyboard connected to the ps/2 port and i want to
send it
some stuff to control his tone indicator.
using c or c++ in linux os. how can i do?

many thanks
Gia
 
S

santosh

skam said:
hi
i need to send an HEX String to the ps/2 port.
i have a special keyboard connected to the ps/2 port and i want to
send it
some stuff to control his tone indicator.
using c or c++ in linux os. how can i do?

You'll have to use an API provided under your implementation. Ask in
either <or
<news:comp.unix.programmer>
 
W

Walter Roberson

i need to send an HEX String to the ps/2 port.
i have a special keyboard connected to the ps/2 port and i want to
send it
some stuff to control his tone indicator.
using c or c++ in linux os. how can i do?

If the port is mapped into the filesystem namespace somehow,
you can fopen() the appropriate filename, and you can
fwrite() or fprintf() any data you want. fprintf() with a %02x format
might be easier than fwrite(), but it depends on how you are building
the string.

That's the limit of what you can do using the standard C libraries.
In practice, it -probably- will not be enough, and you will
-probably- have to use operating-system specific extensions.

Specifically, you will probably have to set the I/O rate
("baud rate") and you may have to set other characteristics as well,
such as indicating that you want "raw" data transfers, and setting
the size of characters and the number of stop bits. The means for
setting particular device characteristics are not part of the C
standard library. Likely, you could use the facilities provided
by POSIX.1 to handle those device conditioning operations.
To start you on your way, I will point you to the POSIX.1 functions
(not part of C itself) tcsetattr() and tcgetattr().
 
J

Johannes Bauer

Walter said:
Specifically, you will probably have to set the I/O rate
("baud rate") and you may have to set other characteristics as well,

No. The keyboard controller of the x86 architecture is something *very*
special. It's mapped in the IO region of the machine and can be accessed
through POSIX.1's ioperm. It behaves *very* different from other devices
(like your comparison to RS232 suggests), namely: The host sets the
clock rate, usually around 30kHz. Transfers are always initiated by the
host. The keyboard controller in the motherboard can also do other fun
stuff (like resetting the computer or masking NMIs - yeah, those "non
maskable interrupts" are maskable after all).

All in all, it's not a good idea.

Greetings,
Johannes
 
M

Marco Manfredini

[...] Likely, you could use the facilities provided
by POSIX.1 to handle those device conditioning operations.
To start you on your way, I will point you to the POSIX.1 functions
(not part of C itself) tcsetattr() and tcgetattr().

This is almost too cruel...
 
W

Walter Roberson

Walter Roberson schrieb:
No. The keyboard controller of the x86 architecture is something *very*
special. It's mapped in the IO region of the machine and can be accessed
through POSIX.1's ioperm.

Hmmm, which POSIX.1 version is that? ioperm() is not found on
opengroup.org

The original poster did not, by the way, specify x86 architecture,
only PS/2 port and linux. PS/2 are pretty much the de facto standard
for keyboards these days, used on many architectures, not just x86.
 
J

Johannes Bauer

Walter said:
Hmmm, which POSIX.1 version is that? ioperm() is not found on
opengroup.org

True, it is really Linux specific.
The original poster did not, by the way, specify x86 architecture,
only PS/2 port and linux. PS/2 are pretty much the de facto standard
for keyboards these days, used on many architectures, not just x86.

Yes he didn't. You're right.

Greetings,
Johannes
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,236
Members
46,822
Latest member
israfaceZa

Latest Threads

Top