notas:programacion:console_ioctls_under_linux
Diferencias
Muestra las diferencias entre dos versiones de la página.
Ambos lados, revisión anteriorRevisión previa | Última revisiónAmbos lados, revisión siguiente | ||
notas:programacion:console_ioctls_under_linux [2011/06/09 18:42] – cayu | notas:programacion:console_ioctls_under_linux [2011/06/09 18:51] – cayu | ||
---|---|---|---|
Línea 5: | Línea 5: | ||
- | The function prototype for ioctl() as defined in / | + | The function prototype for ioctl() as defined in / |
- | is: | + | |
- | int ioctl(int fd, int request, ...) | + | |
- | Technically the ioctl function prototype uses 'int d' but I think 'int | + | <code c> |
- | fd' is a lot clearer. | + | |
+ | </ | ||
- | ' | + | Technically |
- | IOCTL we are requesting (such as KDGETLED), and '...' is argp, the | + | |
- | arguments we are passing to ioctl(). When getting values from ioctl() we | + | |
- | use a pointer and when the function returns, the value will be stored in | + | |
- | our argument. ioctl() is specified in / | + | |
- | We will now briefly describe the IOCTLs, the arguments it uses, and an | + | ' |
- | example on how to use it where applicable. | + | |
+ | We will now briefly describe the IOCTLs, the arguments it uses, and an example on how to use it where applicable. | ||
KDGETLED: | KDGETLED: | ||
- | This will return the current state of the LEDs. These lights on | + | This will return the current state of the LEDs. These lights on your keyboard that are on or off when something such as Caps Lock is on. |
- | | + | Although you can turn the LEDs on or off with KDSETLED (described next) without affecting the Caps Lock, Numeric Lock, or Scroll Lock. |
- | Although you can turn the LEDs on or off with KDSETLED (described next) | + | It places one of the following values (or a combination of them) into a pointer, that points to a long int: |
- | | + | |
- | It places one of the following values (or a combination of them) | + | |
- | | + | |
- | Defined in: / | ||
- | 0x1 - LED_SCR, set when the Scroll Lock LED is on | ||
- | 0x2 - LED_NUM, set when the Numeric Lock LED is on | ||
- | 0x4 - LED_CAP, set when the Caps Lock LED is on | ||
- | As I previously mentioned, it can return combinations (or the sum) | + | Defined |
- | of the LEDs turned on. For example, if the Numeric Lock and Caps Lock | + | |
- | are both on, it will return 0x6 (0x2 + 0x4). So when no lights are on, | + | |
- | it will return 0x0. This is also how you turn all the LEDs off as | + | |
- | described next in KDSETLED. | + | |
- | Example: | + | |
+ | * 0x2 - LED_NUM, set when the Numeric Lock LED is on | ||
+ | * 0x4 - LED_CAP, set when the Caps Lock LED is on | ||
+ | |||
+ | As I previously mentioned, it can return combinations (or the sum) of the LEDs turned on. For example, if the Numeric Lock and Caps Lock are both on, it will return 0x6 (0x2 + 0x4). So when no lights are on, it will return 0x0. This is also how you turn all the LEDs off as described next in KDSETLED. | ||
+ | |||
+ | Example: | ||
<code c> | <code c> | ||
Línea 2045: | Línea 2036: | ||
(which will be 10) and one of the following types: | (which will be 10) and one of the following types: | ||
- | 0: Screen blanking is disabled. | + | * 0: Screen blanking is disabled. |
- | 1: Video adapter registers are saved and the monitor is put into | + | * 1: Video adapter registers are saved and the monitor is put into standby mode (it turns off vertical sychronization pulses). If your monitor has an Off_Mode timer, it will eventually power down by itself. |
- | standby mode (it turns off vertical sychronization pulses). | + | * 2: The settings are saved and then it turns the monitor off (it turns off both vertical and horizontal sychronization pulses. If your monitor doesn' |
- | If your monitor has an Off_Mode timer, it will eventually power | + | |
- | down by itself. | + | |
- | 2: The settings are saved and then it turns the monitor off (it | + | |
- | turns off both vertical and horizontal sychronization pulses. | + | |
- | If your monitor doesn' | + | |
- | your monitor to power down immediately when the blank_timer | + | |
- | times out, use this. | + | |
- | | + | We will use the following structure: |
<code c> | <code c> | ||
Línea 2067: | Línea 2051: | ||
</ | </ | ||
- | | + | Conclusion: |
- | I am sorry for the length of this article, but I wanted to give | + | |
+ | I am sorry for the length of this article, but I wanted to give | ||
examples for many of these to show the uses of console IOCTLs. As I | examples for many of these to show the uses of console IOCTLs. As I | ||
mentioned in the introduction, | mentioned in the introduction, |
notas/programacion/console_ioctls_under_linux.txt · Última modificación: 2011/06/10 12:24 por cayu