C Linux Programming - Read Directly from / Dev

I played with making sounds using mathematical wave functions in C. The next step in my project is to input user input from a MIDI keyboard controller to modulate the waves to different tones.

My first view was that it would be relatively simple and Linux, being Linux, would allow me to read the raw data stream from my device, like any other file.

However, the study overwhelmingly reports that I am writing a device driver for a MIDI controller. The general idea is that even if a device file may be present, the kernel will not know which system calls are being made when my application calls functions such as read () and write ().

Despite these warnings, I did an experiment. I connected a MIDI controller and wrote the device file "/ dev / midi1". A steady stream of null characters appeared, and when I pressed a key on the MIDI controller, several bytes appeared corresponding to the expected pieces of messages that the MIDI device should output. MIDI Protocol Information

So my questions are:

Why does the cat'ed stream behave this way?

Does this mean that the plug and play device driver is already installed on my system?

Should I continue to work and write a device driver, or can I leave with reading it as a file?

Thank you for your advancement to share your wisdom in these areas.

+5
source share
3 answers

Why does the cat'ed stream behave this way?

, -, MIDI-, . , , .

, plug and play?

.

, , MIDI-. , , ​​ , , , read() write().

<... >

, ?

, , , .:) MIDI- - !

+5

, NUL? 0xf8 ? 0xf8 - MIDI , . od:

od -vtx1 /dev/midi1

0xf8, . , MIDI-, , 0xf8.

, MIDI , MIDI ( ), , . , 0xeK ( K - , 0 15), 7 , 7 . , , , - , , , , .

: dmesg MIDI-. , OSS /dev/midi1 (udev ), dmesg , . MIDI - , / . ... , .

, - ( MIDI- , , , , ). , , , , / MIDI. .

ALSA MIDI Linux.

+2

MIDI-, . .

Linux . .

+1

All Articles