I wrote the driver, I have to speak from last year. I said that I started from the participation in the competition, my job is "driver" to write two Linux. When I don't understand anything, check this check That, there is a lot of online, or a confusion. It is just that this thing you do is still doing this thing or the stem of the driver! Of course, I found that "driver" is a bit reluctant.
Describe my actual work: very simple, just connect two serial port devices (GPS modules and card readers) to the PC, my program is to make Linux system identify, set and use these two devices. After reading more and more information, I found that there is not much work I have to do, because the device is connected to the serial port, and the Linux system has provided a function read (), Write (), My job is: 1. Setting the device using the serial port read and write function. 2. Use the serial port read and write function to obtain the data returned by the device. 3. Send data to the device with the serial read and write function. This really doesn't have much technical content. After viewing the specific instructions you need, you can work very quickly. When the main problem is to debug, the serial port is not reactive, and there is no information. In general, the debugging of the bias hardware requires special patience and carefully, but fortunately the serial port is not complex. This called drive is a bit bluff, and the device driver is still accurate. It is built on the serial port driver, that is, the system's serial driver provides a mechanism for serial information transmission. My GPS device driver is responsible for the specific GPS. Module control. Just like telecommunications companies build a phone line between you and me, and I use it to make specific dialogue with you. Behind the source code of the GPS program, the code of the card reader is slightly longer, and it will not take the space: P
In fact, I think in this article is not the writing of the serial device driver, but the organization method of the Linux device driver. Fortunately, I will have the opportunity to write a USB device driver, so it can be coarsely compare the difference between the two drive implementation methods. First look at the GPS driver code attached below, everyone must be very strange when seeing main (), how can the driver be ()? Oh, in fact, this GPS driver is just some functions that implement specific functions. It is white, which is provided to others, and this caller is the app that is demonstrated during our game, which is implemented by calling each GPS driver function to achieve GPS Device control. The main () function you see in the source code is a counterfeit, it is only useful when debugging, and all the functions of all functions are implemented, it is deleted, all functions are provided. Real app,, is it very good ~~
As mentioned earlier, this GPS driver is actually provided to a set of functions for the application, and the application controls the device by them, so they must be all compiled together. In other words, this application is actually an application integrated with the serial port device driver. It can control the GPS module directly through the serial port, very cow, but unfortunately. Most drivers are not such a drop, the driver should be used by many applications, of course, it is impossible to embed the device driver code to use in the application's source code, which is over, the application printer, you have to Drive the printer, use the display to drive the display, not, the driver is mostly independent, and the communication with the application must pass the operating system, which is controlled by the operating system. In Linux, some universal drivers are in the kernel, and other drivers are existing as a module. The USB device driver that I came into contact later was run in the form of kernel modules. It is different from the front GPS driver to: that USB driver is mounted as a module, separated from a Linux system core between the user program, and the GPS driver is directly with the user program, compile together, together Execute, not through the kernel. Said so much, go back and see, dizziness, didn't write anything, I don't know what I want to see ...