基於input子系統的sensor驅動調試(二)

来源:https://www.cnblogs.com/linhaostudy/archive/2018/01/17/8304017.html
-Advertisement-
Play Games

繼上一篇:http://www.cnblogs.com/linhaostudy/p/8303628.html#_label1_1 一、驅動流程解析: 1、模塊載入: of_device_id與DTS中的匹配,這與內核2.6以前的i2c_board_info不一樣; 內核載入驅動模塊的時候將調用到st ...


繼上一篇:http://www.cnblogs.com/linhaostudy/p/8303628.html#_label1_1

一、驅動流程解析:

1、模塊載入:

 1 static struct of_device_id stk_match_table[] = {
 2     { .compatible = "stk,stk3x1x", },
 3     { },
 4 };
 5 
 6 static struct i2c_driver stk_ps_driver =
 7 {
 8     .driver = {
 9         .name = DEVICE_NAME,
10         .owner = THIS_MODULE,
11         .of_match_table = stk_match_table,
12     },
13     .probe = stk3x1x_probe,
14     .remove = stk3x1x_remove,
15     .id_table = stk_ps_id,
16 };
17 
18 
19 static int __init stk3x1x_init(void)
20 {
21     int ret;
22     ret = i2c_add_driver(&stk_ps_driver);
23     if (ret)
24         return ret;
25 
26     return 0;
27 }
28 
29 static void __exit stk3x1x_exit(void)
30 {
31     i2c_del_driver(&stk_ps_driver);
32 }

of_device_id與DTS中的匹配,這與內核2.6以前的i2c_board_info不一樣;

內核載入驅動模塊的時候將調用到stk3x1x_init()方法:

初始化了i2c_driver結構體給stk_ps_driver變數,將用於將設備註冊到IIC。關鍵在於結構體中的probe()方法,註冊完成的時候將調用;

 

2、stk3x1x驅動初始化-probe函數:

  1 static int stk3x1x_probe(struct i2c_client *client,
  2                         const struct i2c_device_id *id)
  3 {
  4     int err = -ENODEV;
  5     struct stk3x1x_data *ps_data;
  6     struct stk3x1x_platform_data *plat_data;
  7     printk(KERN_INFO "%s: driver version = %s\n", __func__, DRIVER_VERSION);
  8 
  9     if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_BYTE_DATA))
 10     {
 11         printk(KERN_ERR "%s: No Support for I2C_FUNC_SMBUS_BYTE_DATA\n", __func__);
 12         return -ENODEV;
 13     }
 14     if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_WORD_DATA))
 15     {
 16         printk(KERN_ERR "%s: No Support for I2C_FUNC_SMBUS_WORD_DATA\n", __func__);
 17         return -ENODEV;
 18     }
 19 
 20     ps_data = kzalloc(sizeof(struct stk3x1x_data),GFP_KERNEL);
 21     if(!ps_data)
 22     {
 23         printk(KERN_ERR "%s: failed to allocate stk3x1x_data\n", __func__);
 24         return -ENOMEM;
 25     }
 26     ps_data->client = client;
 27     i2c_set_clientdata(client,ps_data);
 28     mutex_init(&ps_data->io_lock);
 29     wake_lock_init(&ps_data->ps_wakelock,WAKE_LOCK_SUSPEND, "stk_input_wakelock");
 30 
 31 #ifdef STK_POLL_PS
 32     wake_lock_init(&ps_data->ps_nosuspend_wl,WAKE_LOCK_SUSPEND, "stk_nosuspend_wakelock");
 33 #endif
 34     if (client->dev.of_node) {
 35         plat_data = devm_kzalloc(&client->dev,
 36             sizeof(struct stk3x1x_platform_data), GFP_KERNEL);
 37         if (!plat_data) {
 38             dev_err(&client->dev, "Failed to allocate memory\n");
 39             return -ENOMEM;
 40         }
 41 
 42         err = stk3x1x_parse_dt(&client->dev, plat_data);
 43         dev_err(&client->dev,
 44             "%s: stk3x1x_parse_dt ret=%d\n", __func__, err);
 45         if (err)
 46             return err;
 47     } else
 48         plat_data = client->dev.platform_data;
 49 
 50     if (!plat_data) {
 51         dev_err(&client->dev,
 52             "%s: no stk3x1x platform data!\n", __func__);
 53         goto err_als_input_allocate;
 54     }
 55     ps_data->als_transmittance = plat_data->transmittance;
 56     ps_data->int_pin = plat_data->int_pin;
 57     ps_data->use_fir = plat_data->use_fir;
 58     ps_data->pdata = plat_data;
 59 
 60     if (ps_data->als_transmittance == 0) {
 61         dev_err(&client->dev,
 62             "%s: Please set als_transmittance\n", __func__);
 63         goto err_als_input_allocate;
 64     }
 65 
 66     ps_data->als_input_dev = devm_input_allocate_device(&client->dev);
 67     if (ps_data->als_input_dev==NULL)
 68     {
 69         printk(KERN_ERR "%s: could not allocate als device\n", __func__);
 70         err = -ENOMEM;
 71         goto err_als_input_allocate;
 72     }
 73     ps_data->ps_input_dev = devm_input_allocate_device(&client->dev);
 74     if (ps_data->ps_input_dev==NULL)
 75     {
 76         printk(KERN_ERR "%s: could not allocate ps device\n", __func__);
 77         err = -ENOMEM;
 78         goto err_als_input_allocate;
 79     }
 80     ps_data->als_input_dev->name = ALS_NAME;
 81     ps_data->ps_input_dev->name = PS_NAME;
 82     set_bit(EV_ABS, ps_data->als_input_dev->evbit);
 83     set_bit(EV_ABS, ps_data->ps_input_dev->evbit);
 84     input_set_abs_params(ps_data->als_input_dev, ABS_MISC, 0, stk_alscode2lux(ps_data, (1<<16)-1), 0, 0);
 85     input_set_abs_params(ps_data->ps_input_dev, ABS_DISTANCE, 0,1, 0, 0);
 86     err = input_register_device(ps_data->als_input_dev);
 87     if (err<0)
 88     {
 89         printk(KERN_ERR "%s: can not register als input device\n", __func__);
 90         goto err_als_input_allocate;
 91     }
 92     err = input_register_device(ps_data->ps_input_dev);
 93     if (err<0)
 94     {
 95         printk(KERN_ERR "%s: can not register ps input device\n", __func__);
 96         goto err_als_input_allocate;
 97     }
 98 
 99     err = sysfs_create_group(&ps_data->als_input_dev->dev.kobj, &stk_als_attribute_group);
100     if (err < 0)
101     {
102         printk(KERN_ERR "%s:could not create sysfs group for als\n", __func__);
103         goto err_als_input_allocate;
104     }
105     err = sysfs_create_group(&ps_data->ps_input_dev->dev.kobj, &stk_ps_attribute_group);
106     if (err < 0)
107     {
108         printk(KERN_ERR "%s:could not create sysfs group for ps\n", __func__);
109         goto err_ps_sysfs_create_group;
110     }
111     input_set_drvdata(ps_data->als_input_dev, ps_data);
112     input_set_drvdata(ps_data->ps_input_dev, ps_data);
113 
114 #ifdef STK_POLL_ALS
115     ps_data->stk_als_wq = create_singlethread_workqueue("stk_als_wq");
116     INIT_WORK(&ps_data->stk_als_work, stk_als_work_func);
117     hrtimer_init(&ps_data->als_timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
118     ps_data->als_poll_delay = ns_to_ktime(110 * NSEC_PER_MSEC);
119     ps_data->als_timer.function = stk_als_timer_func;
120 #endif
121 
122     ps_data->stk_ps_wq = create_singlethread_workqueue("stk_ps_wq");
123     INIT_WORK(&ps_data->stk_ps_work, stk_ps_work_func);
124     hrtimer_init(&ps_data->ps_timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
125     ps_data->ps_poll_delay = ns_to_ktime(110 * NSEC_PER_MSEC);
126     ps_data->ps_timer.function = stk_ps_timer_func;
127 #if (!defined(STK_POLL_ALS) || !defined(STK_POLL_PS))
128     ps_data->stk_wq = create_singlethread_workqueue("stk_wq");
129     INIT_WORK(&ps_data->stk_work, stk_work_func);
130     err = stk3x1x_setup_irq(client);
131     if(err < 0)
132         goto err_stk3x1x_setup_irq;
133 #endif
134 
135     err = stk3x1x_power_init(ps_data, true);
136     if (err)
137         goto err_power_init;
138 
139     err = stk3x1x_power_ctl(ps_data, true);
140     if (err)
141         goto err_power_on;
142 
143     ps_data->als_enabled = false;
144     ps_data->ps_enabled = false;
145 #ifdef CONFIG_HAS_EARLYSUSPEND
146     ps_data->stk_early_suspend.level = EARLY_SUSPEND_LEVEL_BLANK_SCREEN + 1;
147     ps_data->stk_early_suspend.suspend = stk3x1x_early_suspend;
148     ps_data->stk_early_suspend.resume = stk3x1x_late_resume;
149     register_early_suspend(&ps_data->stk_early_suspend);
150 #endif
151     /* make sure everything is ok before registering the class device */
152     ps_data->als_cdev = sensors_light_cdev;
153     ps_data->als_cdev.sensors_enable = stk_als_enable_set;
154     ps_data->als_cdev.sensors_poll_delay = stk_als_poll_delay_set;
155     err = sensors_classdev_register(&client->dev, &ps_data->als_cdev);
156     if (err)
157         goto err_power_on;
158 
159     ps_data->ps_cdev = sensors_proximity_cdev;
160     ps_data->ps_cdev.sensors_enable = stk_ps_enable_set;
161     err = sensors_classdev_register(&client->dev, &ps_data->ps_cdev);
162     if (err)
163         goto err_class_sysfs;
164 
165     /* enable device power only when it is enabled */
166     err = stk3x1x_power_ctl(ps_data, false);
167     if (err)
168         goto err_init_all_setting;
169 
170     dev_dbg(&client->dev, "%s: probe successfully", __func__);
171 
172     return 0;
173 
174 err_init_all_setting:
175     stk3x1x_power_ctl(ps_data, false);
176     sensors_classdev_unregister(&ps_data->ps_cdev);
177 err_class_sysfs:
178     sensors_classdev_unregister(&ps_data->als_cdev);
179 err_power_on:
180     stk3x1x_power_init(ps_data, false);
181 err_power_init:
182 #ifndef STK_POLL_PS
183     free_irq(ps_data->irq, ps_data);
184     gpio_free(plat_data->int_pin);
185 #endif
186 #if (!defined(STK_POLL_ALS) || !defined(STK_POLL_PS))
187 err_stk3x1x_setup_irq:
188 #endif
189 #ifdef STK_POLL_ALS
190     hrtimer_try_to_cancel(&ps_data->als_timer);
191     destroy_workqueue(ps_data->stk_als_wq);
192 #endif
193     destroy_workqueue(ps_data->stk_ps_wq);
194 #if (!defined(STK_POLL_ALS) || !defined(STK_POLL_PS))
195     destroy_workqueue(ps_data->stk_wq);
196 #endif
197     sysfs_remove_group(&ps_data->ps_input_dev->dev.kobj, &stk_ps_attribute_group);
198 err_ps_sysfs_create_group:
199     sysfs_remove_group(&ps_data->als_input_dev->dev.kobj, &stk_als_attribute_group);
200 err_als_input_allocate:
201 #ifdef STK_POLL_PS
202     wake_lock_destroy(&ps_data->ps_nosuspend_wl);
203 #endif
204     wake_lock_destroy(&ps_data->ps_wakelock);
205     mutex_destroy(&ps_data->io_lock);
206     kfree(ps_data);
207     return err;
208 }
View Code

 在stk3x1x_probe函數中主要做了:

1、為驅動私有數據結構體stk3x1x_data分配記憶體空間;

2、 將設備驅動的私有數據(stk3x1x_data)連接到設備client(i2c_client)中;(bma255會增加一步:讀取i2c的id);

3、將stk3x1x驅動註冊到linux input子系統;

4、創建工作隊列(主要是對sensor的數據採集);

5、創建sysfs介面;

2.1 創建input子系統:

http://blog.csdn.net/ielife/article/details/7798952

1、 在驅動載入模塊中,設置你的input設備支持的事件類型;

2、 註冊中斷處理函數,例如鍵盤設備需要編寫按鍵的抬起、放下,觸摸屏設備需要編寫按下、抬起、絕對移動,滑鼠設備需要編寫單擊、抬起、相對移動,並且需要在必要的時候提交硬體數據(鍵值/坐標/狀態等等);

3、將輸入設備註冊到輸入子系統中;

 1   ps_data->als_input_dev = devm_input_allocate_device(&client->dev);    //分配記憶體空間
 2     if (ps_data->als_input_dev==NULL)
 3     {
 4         printk(KERN_ERR "%s: could not allocate als device\n", __func__);
 5         err = -ENOMEM;
 6         goto err_als_input_allocate;
 7     }
 8     ps_data->ps_input_dev = devm_input_allocate_device(&client->dev);
 9     if (ps_data->ps_input_dev==NULL)
10     {
11         printk(KERN_ERR "%s: could not allocate ps device\n", __func__);
12         err = -ENOMEM;
13         goto err_als_input_allocate;
14     }
15     ps_data->als_input_dev->name = ALS_NAME;     
16     ps_data->ps_input_dev->name = PS_NAME;
17     set_bit(EV_ABS, ps_data->als_input_dev->evbit);
18     set_bit(EV_ABS, ps_data->ps_input_dev->evbit);
19     input_set_abs_params(ps_data->als_input_dev, ABS_MISC, 0, stk_alscode2lux(ps_data, (1<<16)-1), 0, 0);    //設置input載入類型;
20     input_set_abs_params(ps_data->ps_input_dev, ABS_DISTANCE, 0,1, 0, 0);
21     err = input_register_device(ps_data->als_input_dev);
22     if (err<0)
23     {
24         printk(KERN_ERR "%s: can not register als input device\n", __func__);
25         goto err_als_input_allocate;
26     }
27     err = input_register_device(ps_data->ps_input_dev);
28     if (err<0)
29     {
30         printk(KERN_ERR "%s: can not register ps input device\n", __func__);
31         goto err_als_input_allocate;
32     }
1     err = stk3x1x_setup_irq(client);        //設置驅動中斷函數
2     if(err < 0)
3         goto err_stk3x1x_setup_irq;

 

 

 

2.2 創建工作隊列:

先提一個問題,為什麼要創建工作隊列?在前面的介紹中我們知道,sensor感測器獲取數據後,將數據傳給controller的寄存器中,供主控去查詢讀取數據。所以這裡創建的工作隊列,就是在一個工作者線程,通過IIC不斷的去查詢讀取controller上的數據。

工作隊列的作用就是把工作推後,交由一個內核線程去執行,更直接的說就是如果寫了一個函數,而現在不想馬上執行它,想在將來某個時刻去執行它,那用工作隊列準沒錯.大概會想到中斷也是這樣,提供一個中斷服務函數,在發生中斷的時候去執行,沒錯,和中斷相比,工作隊列最大的好處就是可以調度可以睡眠,靈活性更好。

上面代碼中我們看到INIT_WORK(&ps_data->stk_ps_work, stk_ps_work_func);,其實是一個巨集的定義,在include/linux/workqueue.h中。stk_ps_work_func()就是我們定義的功能函數,用於查詢讀取Sensor的距離感測器數據的,並上報Input子系統,代碼如下:

 1 static void stk_ps_work_func(struct work_struct *work)
 2 {
 3     struct stk3x1x_data *ps_data = container_of(work, struct stk3x1x_data, stk_ps_work);
 4     uint32_t reading;
 5     int32_t near_far_state;
 6     uint8_t org_flag_reg;
 7     int32_t ret;
 8     uint8_t disable_flag = 0;
 9     mutex_lock(&ps_data->io_lock);
10 
11     org_flag_reg = stk3x1x_get_flag(ps_data);
12     if(org_flag_reg < 0)
13     {
14         printk(KERN_ERR "%s: get_status_reg fail, ret=%d", __func__, org_flag_reg);
15         goto err_i2c_rw;
16     }
17     near_far_state = (org_flag_reg & STK_FLG_NF_MASK)?1:0;
18     reading = stk3x1x_get_ps_reading(ps_data);
19     if(ps_data->ps_distance_last != near_far_state)
20     {
21         ps_data->ps_distance_last = near_far_state;
22         input_report_abs(ps_data->ps_input_dev, ABS_DISTANCE, near_far_state);    //input上報數據
23         input_sync(ps_data->ps_input_dev);                    //input_sync()在這裡不起關鍵作用。但如果是一個觸摸屏,即有x坐標和y坐標,則需要通過input_sync()函數把x和y坐標完整地傳遞給輸入子系統。
24         wake_lock_timeout(&ps_data->ps_wakelock, 3*HZ);
25 #ifdef STK_DEBUG_PRINTF
26         printk(KERN_INFO "%s: ps input event %d cm, ps code = %d\n",__func__, near_far_state, reading);
27 #endif
28     }
29     ret = stk3x1x_set_flag(ps_data, org_flag_reg, disable_flag);
30     if(ret < 0)
31     {
32         printk(KERN_ERR "%s:stk3x1x_set_flag fail, ret=%d\n", __func__, ret);
33         goto err_i2c_rw;
34     }
35 
36     mutex_unlock(&ps_data->io_lock);
37     return;
38 
39 err_i2c_rw:
40     mutex_unlock(&ps_data->io_lock);
41     msleep(30);
42     return;
43 }

 

 2.3 創建sysfs介面:

為什麼要創建sysfs介面?在驅動層創建了sysfs介面,HAL層通過這些sysfs介面,對Sensor進行操作,如使能、設置delay等。

 

DEVICE_ATTR的使用:http://blog.csdn.net/njuitjf/article/details/16849333

 

函數巨集DEVICE_ATTR內封裝的是__ATTR(_name,_mode,_show,_stroe)方法:

 _show:表示的是讀方法,_stroe表示的是寫方法。

1、 調用巨集DEVICE_ATTR完成對功能函數的註冊:

 1 static struct device_attribute ps_enable_attribute = __ATTR(enable,0664,stk_ps_enable_show,stk_ps_enable_store);
 2 static struct device_attribute ps_enable_aso_attribute = __ATTR(enableaso,0664,stk_ps_enable_aso_show,stk_ps_enable_aso_store);
 3 static struct device_attribute ps_distance_attribute = __ATTR(distance,0664,stk_ps_distance_show, stk_ps_distance_store);
 4 static struct device_attribute ps_offset_attribute = __ATTR(offset,0664,stk_ps_offset_show, stk_ps_offset_store);
 5 static struct device_attribute ps_code_attribute = __ATTR(code, 0444, stk_ps_code_show, NULL);
 6 static struct device_attribute ps_code_thd_l_attribute = __ATTR(codethdl,0664,stk_ps_code_thd_l_show,stk_ps_code_thd_l_store);
 7 static struct device_attribute ps_code_thd_h_attribute = __ATTR(codethdh,0664,stk_ps_code_thd_h_show,stk_ps_code_thd_h_store);
 8 static struct device_attribute recv_attribute = __ATTR(recv,0664,stk_recv_show,stk_recv_store);
 9 static struct device_attribute send_attribute = __ATTR(send,0664,stk_send_show, stk_send_store);
10 static struct device_attribute all_reg_attribute = __ATTR(allreg, 0444, stk_all_reg_show, NULL);
11 
12 static struct attribute *stk_ps_attrs [] =
13 {
14     &ps_enable_attribute.attr,
15     &ps_enable_aso_attribute.attr,
16     &ps_distance_attribute.attr,
17     &ps_offset_attribute.attr,
18     &ps_code_attribute.attr,
19     &ps_code_thd_l_attribute.attr,
20     &ps_code_thd_h_attribute.attr,
21     &recv_attribute.attr,
22     &send_attribute.attr,
23     &all_reg_attribute.attr,
24     NULL
25 };
26 
27 static struct attribute_group stk_ps_attribute_group = {
28     .attrs = stk_ps_attrs,
29 };

 

在probe函數中:

 1   err = sysfs_create_group(&ps_data->als_input_dev->dev.kobj, &stk_als_attribute_group);
 2     if (err < 0)
 3     {
 4         printk(KERN_ERR "%s:could not create sysfs group for als\n", __func__);
 5         goto err_als_input_allocate;
 6     }
 7     err = sysfs_create_group(&ps_data->ps_input_dev->dev.kobj, &stk_ps_attribute_group);
 8     if (err < 0)
 9     {
10         printk(KERN_ERR "%s:could not create sysfs group for ps\n", __func__);
11         goto err_ps_sysfs_create_group;
12     }

 

到此,完成了sysfs介面的創建,我們可以在根文件系統中看到/sys/class/input/input1/目錄,在該目錄下我們可以看到多個節點,其中就包含了enable和delay。我們以enable為例子,可以有兩種方法完成對Gsensor的使能工作:

 

3、讀取上報數據:

Android的HAL層,通過對/sys/class/input/input3/enable節點的寫操作,使能sensor。調用到的方法是stk_ps_enable_store函數:

 1 static struct device_attribute ps_enable_attribute = __ATTR(enable,0664,stk_ps_enable_show,stk_ps_enable_store);
 2 static struct device_attribute ps_enable_aso_attribute = __ATTR(enableaso,0664,stk_ps_enable_aso_show,stk_ps_enable_aso_store);
 3 static struct device_attribute ps_distance_attribute = __ATTR(distance,0664,stk_ps_distance_show, stk_ps_distance_store);
 4 static struct device_attribute ps_offset_attribute = __ATTR(offset,0664,stk_ps_offset_show, stk_ps_offset_store);
 5 static struct device_attribute ps_code_attribute = __ATTR(code, 0444, stk_ps_code_show, NULL);
 6 static struct device_attribute ps_code_thd_l_attribute = __ATTR(codethdl,0664,stk_ps_code_thd_l_show,stk_ps_code_thd_l_store);
 7 static struct device_attribute ps_code_thd_h_attribute = __ATTR(codethdh,0664,stk_ps_code_thd_h_show,stk_ps_code_thd_h_store);
 8 static struct device_attribute recv_attribute = __ATTR(recv,0664,stk_recv_show,stk_recv_store);
 9 static struct device_attribute send_attribute = __ATTR(send,0664,stk_send_show, stk_send_store);
10 static struct device_attribute all_reg_attribute = __ATTR(allreg, 0444, stk_all_reg_show, NULL);

 

 裡面的show和store函數;

 1 static ssize_t stk_ps_enable_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t size)
 2 {
 3     struct stk3x1x_data *ps_data =  dev_get_drvdata(dev);
 4     uint8_t en;
 5     if (sysfs_streq(buf, "1"))
 6         en = 1;
 7     else if (sysfs_streq(buf, "0"))
 8         en = 0;
 9     else
10     {
11         printk(KERN_ERR "%s, invalid value %d\n", __func__, *buf);
12         return -EINVAL;
13     }
14     dev_dbg(dev, "%s: Enable PS : %d\n", __func__, en);
15     mutex_lock(&ps_data->io_lock);
16     stk3x1x_enable_ps(ps_data, en);
17     mutex_unlock(&ps_data->io_lock);
18     return size;
19 }

 

您的分享是我們最大的動力!

-Advertisement-
Play Games
更多相關文章
  • Form提供了兩種數據傳輸的方式:get和post。雖然它們都是數據的提交方式,但是在實際傳輸時確有很大的不同,並且可能會對數據產生嚴重的影響。 Form中的get和post方法,在數據傳輸過程中分別對應了HTTP協議中的GET和POST方法。二者主要區別如下: 1、Get是用來從伺服器上獲得數據, ...
  • 字元串 在底層上跟C 類似,每個字元串的實例都不可修改。當修改字元串變數時,是將變數指向新的字元串實例,而不是修改原本的實例。Java中也有字元串池機制。 註意:使用 運算符比較字元串時,跟C 有根本上的差別。在Java中這裡的 操作符相當於C 中的 方法。 Java中比較字元串要使用 方法,忽略大 ...
  • 什麼事邊角料? 邊角料就是你編程的時候,很少能夠用上,或者說你壓根就不知道得東西,我就稱這些東西為邊角料。這個叫.net邊角料可能有點大,其實這個系列是純粹的C#邊角料系列。 為什麼寫.net邊角料呢,因為.net coder越來越少了,所以邊角的東西,知道的人也越來越少,雖然價值不大,但是要抱著拋 ...
  • 這個是我剛入行第一個感興趣的知識點,翻了翻不知道什麼時候記的筆記,覺得有必要把自己學的知識在梳理一遍,有一些點比當時更清晰;在這裡,先將一位大牛的博客貼出來,有興趣的可以去看看,很詳細的介紹了委托與事件,讀了幾遍受益匪淺: C# 中的委托和事件 C#中的委托和事件(續) 本文實例是在VS2013下實 ...
  • Infi-chu: http://www.cnblogs.com/Infi-chu/ 一、所需工具及必要條件: 1. 首先需要一個大於16GB U盤。 2.電腦系統版本應該大於10.11.X(因為之前我的電腦版本是10.11.X,在下載新的鏡像之後大小隻有十幾兆,而官方的大小顯示為4.8GB,之後的 ...
  • ———————————————————————————————————————————————————————————————— 在上一篇文章中,我們已經看到 IopParseDevice() 如何對傳入的 OPEN_PACKET 結構進行驗證。假設 ObReferenceObjectByName( ...
  • 安裝Docker 安裝Docker Docker 軟體包已經包括在預設的 CentOS Extras 軟體源里。因此想要安裝 docker,只需要運行下麵的 yum 命令: 查看安裝後的版本號 直接yum安裝,安裝成功後查看版本 啟動Docker 設置開機啟動 這裡這一步可以忽略,但是為了你的Lin ...
  • 1、登錄阿裡雲(www.aliyun.com) -- 》 控制台; 2、點擊左邊的“雲伺服器ECS”: 3、點擊上面“第二步”,進入頁面之後,點擊“管理”功能: 4、進入管理頁之後,點擊“停止”按鈕(只有先停止,才能初始化磁碟): 5、初始化時,選擇“設置密碼”(此時設置的是SSH登錄密碼): 設置 ...
一周排行
    -Advertisement-
    Play Games
  • 移動開發(一):使用.NET MAUI開發第一個安卓APP 對於工作多年的C#程式員來說,近來想嘗試開發一款安卓APP,考慮了很久最終選擇使用.NET MAUI這個微軟官方的框架來嘗試體驗開發安卓APP,畢竟是使用Visual Studio開發工具,使用起來也比較的順手,結合微軟官方的教程進行了安卓 ...
  • 前言 QuestPDF 是一個開源 .NET 庫,用於生成 PDF 文檔。使用了C# Fluent API方式可簡化開發、減少錯誤並提高工作效率。利用它可以輕鬆生成 PDF 報告、發票、導出文件等。 項目介紹 QuestPDF 是一個革命性的開源 .NET 庫,它徹底改變了我們生成 PDF 文檔的方 ...
  • 項目地址 項目後端地址: https://github.com/ZyPLJ/ZYTteeHole 項目前端頁面地址: ZyPLJ/TreeHoleVue (github.com) https://github.com/ZyPLJ/TreeHoleVue 目前項目測試訪問地址: http://tree ...
  • 話不多說,直接開乾 一.下載 1.官方鏈接下載: https://www.microsoft.com/zh-cn/sql-server/sql-server-downloads 2.在下載目錄中找到下麵這個小的安裝包 SQL2022-SSEI-Dev.exe,運行開始下載SQL server; 二. ...
  • 前言 隨著物聯網(IoT)技術的迅猛發展,MQTT(消息隊列遙測傳輸)協議憑藉其輕量級和高效性,已成為眾多物聯網應用的首選通信標準。 MQTTnet 作為一個高性能的 .NET 開源庫,為 .NET 平臺上的 MQTT 客戶端與伺服器開發提供了強大的支持。 本文將全面介紹 MQTTnet 的核心功能 ...
  • Serilog支持多種接收器用於日誌存儲,增強器用於添加屬性,LogContext管理動態屬性,支持多種輸出格式包括純文本、JSON及ExpressionTemplate。還提供了自定義格式化選項,適用於不同需求。 ...
  • 目錄簡介獲取 HTML 文檔解析 HTML 文檔測試參考文章 簡介 動態內容網站使用 JavaScript 腳本動態檢索和渲染數據,爬取信息時需要模擬瀏覽器行為,否則獲取到的源碼基本是空的。 本文使用的爬取步驟如下: 使用 Selenium 獲取渲染後的 HTML 文檔 使用 HtmlAgility ...
  • 1.前言 什麼是熱更新 游戲或者軟體更新時,無需重新下載客戶端進行安裝,而是在應用程式啟動的情況下,在內部進行資源或者代碼更新 Unity目前常用熱更新解決方案 HybridCLR,Xlua,ILRuntime等 Unity目前常用資源管理解決方案 AssetBundles,Addressable, ...
  • 本文章主要是在C# ASP.NET Core Web API框架實現向手機發送驗證碼簡訊功能。這裡我選擇是一個互億無線簡訊驗證碼平臺,其實像阿裡雲,騰訊雲上面也可以。 首先我們先去 互億無線 https://www.ihuyi.com/api/sms.html 去註冊一個賬號 註冊完成賬號後,它會送 ...
  • 通過以下方式可以高效,並保證數據同步的可靠性 1.API設計 使用RESTful設計,確保API端點明確,並使用適當的HTTP方法(如POST用於創建,PUT用於更新)。 設計清晰的請求和響應模型,以確保客戶端能夠理解預期格式。 2.數據驗證 在伺服器端進行嚴格的數據驗證,確保接收到的數據符合預期格 ...