On Thu, 28 Mar 2019 14:53:28 -0700, Dave Stevens said: > In the article below about kernel updates is a reference to a driver for > a Plantower PMS7003 particulate matter sensor. I'm using this series in > air pollution monitoring and its usual interface to the computer > is over a serial line. I consequently am very curious about how and why > it would need a specific kernel module. A quick look at the driver shows that it apparently does at least a little bit of the heavy lifting for you - rather than you have to do all the serial I/O interpretation yourself in userspace, it will handle checksums and channels and so on for you. +enum pms7003_cmd { + CMD_WAKEUP, + CMD_ENTER_PASSIVE_MODE, + CMD_READ_PASSIVE, + CMD_SLEEP, +}; + +/* + * commands have following format: + * + * +------+------+-----+------+-----+-----------+-----------+ + * | 0x42 | 0x4d | cmd | 0x00 | arg | cksum msb | cksum lsb | + * +------+------+-----+------+-----+-----------+-----------+ + */ +static const u8 pms7003_cmd_tbl[][PMS7003_CMD_LENGTH] = { + [CMD_WAKEUP] = { 0x42, 0x4d, 0xe4, 0x00, 0x01, 0x01, 0x74 }, + [CMD_ENTER_PASSIVE_MODE] = { 0x42, 0x4d, 0xe1, 0x00, 0x00, 0x01, 0x70 }, + [CMD_READ_PASSIVE] = { 0x42, 0x4d, 0xe2, 0x00, 0x00, 0x01, 0x71 }, + [CMD_SLEEP] = { 0x42, 0x4d, 0xe4, 0x00, 0x00, 0x01, 0x73 }, +}; So you can send 'wakeup' or 'read' and it will send the strings, and then read back data and complete the I/O when enough bytes have arrived. There's also some probing in there to deal with device tree etc. _______________________________________________ Kernelnewbies mailing list Kernelnewbies@xxxxxxxxxxxxxxxxx https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies