tailieunhanh - Embedded FreeBSD Cookbook phần 7

Khi một dịch vụ mạng là đóng cửa, dọn dẹp thích hợp được khuyến khích. Mô tả ổ cắm phải được đóng cửa, bằng cách sử dụng cuộc gọi hệ thống chặt chẽ, giống như một mô tả tập tin. # bao gồm gần int (int fd); | 136 Embedded FreeBSD Cookbook else printf illegal state n return if dio set int s 0 printf set int failed n Listing 7-7 The int_handler function parses the user input looking for either the enable or disable string to determine the interrupt setting. If the user input is correct dio_set_int is called to set the interrupt state. The pciint_handler Function The pciint_handler function is used to set pci interrupts. The pciint command is entered using the following syntax pciint value where value is either the string enable or disable. void pciint handler char args uint8 t p char state 32 DIOintstate t s sscanf args s s state if strcmp state enable 0 strcmp state ENABLE 0 s enable else if strcmp state disable 0 strcmp state DISABLE 0 s disable 137 Chapter Seven Remote Management else printf illegal state n return if dio set pciint s 0 printf set pciint failed n Listing 7-8 The pciint_handler function parses the user input looking for either the enable or disable string to determine the interrupt setting. If the user input is correct dio_set_pciint is called to set the interrupt state. The setpolarity_handler Function The setpolarity_handler function is used to set the interrupt polarity. The set polarity command is entered using the following syntax setpol value where value is either high or low. void setpolarity handler char args uint8 t p char state 32 DIOpolarity_t polarity sscanf args s s state if strcmp state hi 0 strcmp state HI 0 polarity activehi else if strcmp state lo 0 strcmp state LO 0 polarity activelo 138 Embedded FreeBSD Cookbook else printf invalid polarity n return if dio set polarity polarity 0 printf error writing polarity n Listing 7-9 The int_handler function parses the user input looking for either the high or low string to determine the interrupt polarity setting. If the user input is correct dio_set_polarity is called to set the interrupt polarity. The getpolarity_handler Function The getpolarity_handler function is used to read the interrupt .

TỪ KHÓA LIÊN QUAN