做漂亮的二维码网站,wordpress数组,免费logo设计软件手机版,大型网站开发流程第一次使用web控制一个实体硬件#xff0c;需要通过网页调用串口#xff0c;摸索了一阵子#xff0c;终于选定用pythonphpjQueryhtml实现了。 第一部分#xff1a;web首页界面 index.html!DOCTYPE htmlhtml langenheadmeta charse… 第一次使用web控制一个实体硬件需要通过网页调用串口摸索了一阵子终于选定用pythonphpjQueryhtml实现了。 第一部分web首页界面 index.html!DOCTYPE htmlhtml langenheadmeta charsetUTF-8title继电器调控测试/titlescript src/public/js/jquery.js/scriptscript$(document).ready(function(){$(input).each(function(){$(this).bind(click,function(){com($(this)[0].checked,$(this).attr(lu))})})})function com(s,lu){$.ajax({type:get,async:true,timeout : 20000,//20秒url: http://bsfx.longsunhd.com:60096/jdq.php?luluss,data: ,dataType: html,success: function(html){}});}/script/headbodyinput typecheckbox onFE 05 00 00 FF 00 98 35 offFE 05 00 00 00 00 D9 C5 lu0第1路brinput typecheckbox onFE 05 00 01 FF 00 C9 F5 offFE 05 00 01 00 00 88 05 lu1第2路brinput typecheckbox onFE 05 00 02 FF 00 39 F5 offFE 05 00 02 00 00 78 05 lu2第3路brinput typecheckbox onFE 05 00 03 FF 00 68 35 offFE 05 00 03 00 00 29 C5 lu3第4路brinput typecheckbox onFE 05 00 04 FF 00 D9 F4 offFE 05 00 04 00 00 98 04 lu4第5路brinput typecheckbox onFE 05 00 05 FF 00 88 34 offFE 05 00 05 00 00 C9 C4 lu5第6路brinput typecheckbox onFE 05 00 06 FF 00 78 34 offFE 05 00 06 00 00 39 C4 lu6第7路brinput typecheckbox onFE 05 00 07 FF 00 29 F4 offFE 05 00 07 00 00 68 04 lu7第8路brinput typecheckbox onFE 05 00 08 FF 00 19 F7 offFE 05 00 08 00 00 58 07 lu8第9路brinput typecheckbox onFE 05 00 09 FF 00 48 37 offFE 05 00 09 00 00 09 C7 lu9第10路brinput typecheckbox onFE 05 00 0A FF 00 B8 37 offFE 05 00 0A 00 00 F9 C7 lu10第11路brinput typecheckbox onFE 05 00 0B FF 00 E9 F7 offFE 05 00 0B 00 00 A8 07 lu11第12路brinput typecheckbox onFE 05 00 0C FF 00 58 36 offFE 05 00 0C 00 00 19 C6 lu12第13路brinput typecheckbox onFE 05 00 0D FF 00 09 F6 offFE 05 00 0D 00 00 48 06 lu13第14路brinput typecheckbox onFE 05 00 0E FF 00 F9 F6 offFE 05 00 0E 00 00 B8 06 lu14第15路brinput typecheckbox onFE 05 00 0F FF 00 A8 36 offFE 05 00 0F 00 00 E9 C6 lu15第16路brinput typecheckbox onFE 05 00 10 FF 00 99 F0 offFE 05 00 10 00 00 D8 00 lu16第17路brinput typecheckbox onFE 05 00 11 FF 00 C8 30 offFE 05 00 11 00 00 89 C0 lu17第18路brinput typecheckbox onFE 05 00 12 FF 00 38 30 offFE 05 00 12 00 00 79 C0 lu18第19路brinput typecheckbox onFE 05 00 13 FF 00 69 F0 offFE 05 00 13 00 00 28 00 lu19第20路brinput typecheckbox onFE 05 00 14 FF 00 D8 31 offFE 05 00 14 00 00 99 C1 lu20第21路brinput typecheckbox onFE 05 00 15 FF 00 89 F1 offFE 05 00 15 00 00 C8 01 lu21第22路brinput typecheckbox onFE 05 00 16 FF 00 79 F1 offFE 05 00 16 00 00 38 01 lu22第23路brinput typecheckbox onFE 05 00 17 FF 00 28 31 offFE 05 00 17 00 00 69 C1 lu23第24路brinput typecheckbox onFE 05 00 18 FF 00 18 32 offFE 05 00 18 00 00 59 C2 lu24第25路brinput typecheckbox onFE 05 00 19 FF 00 49 F2 offFE 05 00 19 00 00 08 02 lu25第26路brinput typecheckbox onFE 05 00 1A FF 00 B9 F2 offFE 05 00 1A 00 00 F8 02 lu26第27路brinput typecheckbox onFE 05 00 1B FF 00 E8 32 offFE 05 00 1B 00 00 A9 C2 lu27第28路brinput typecheckbox onFE 05 00 1C FF 00 59 F3 offFE 05 00 1C 00 00 18 03 lu28第29路brinput typecheckbox onFE 05 00 1D FF 00 08 33 offFE 05 00 1D 00 00 49 C3 lu29第30路brinput typecheckbox onFE 05 00 1E FF 00 F8 33 offFE 05 00 1E 00 00 B9 C3 lu30第31路brinput typecheckbox onFE 05 00 1F FF 00 A9 F3 offFE 05 00 1F 00 00 E8 03 lu31第32路brbrinput typecheckbox onFE 05 00 1F FF 00 A9 F3 offFE 05 00 1F 00 00 E8 03 lu32全路br/body/html第二部分 jdq.php?php$_REQUEST[s]($_REQUEST[s]true)?0:1;$resultshell_exec(D:/Python/python.exe com.py $_REQUEST[lu] $_REQUEST[s]); 第三部分 COM.py from sys import argvimport serialimport stringimport timeimport binasciiimport sysimport structimport ref,lu,s argvcm[]cm.append([[0xFE,0x05,0x00,0x00,0xFF,0x00,0x98,0x35],[0xFE,0x05,0x00,0x00,0x00,0x00,0xD9,0xC5]])cm.append([[0xFE,0x05,0x00,0x01,0xFF,0x00,0xC9,0xF5],[0xFE,0x05,0x00,0x01,0x00,0x00,0x88,0x05]])cm.append([[0xFE,0x05,0x00,0x02,0xFF,0x00,0x39,0xF5],[0xFE,0x05,0x00,0x02,0x00,0x00,0x78,0x05]])cm.append([[0xFE,0x05,0x00,0x03,0xFF,0x00,0x68,0x35],[0xFE,0x05,0x00,0x03,0x00,0x00,0x29,0xC5]])cm.append([[0xFE,0x05,0x00,0x04,0xFF,0x00,0xD9,0xF4],[0xFE,0x05,0x00,0x04,0x00,0x00,0x98,0x04]])cm.append([[0xFE,0x05,0x00,0x05,0xFF,0x00,0x88,0x34],[0xFE,0x05,0x00,0x05,0x00,0x00,0xC9,0xC4]])cm.append([[0xFE,0x05,0x00,0x06,0xFF,0x00,0x78,0x34],[0xFE,0x05,0x00,0x06,0x00,0x00,0x39,0xC4]])cm.append([[0xFE,0x05,0x00,0x07,0xFF,0x00,0x29,0xF4],[0xFE,0x05,0x00,0x07,0x00,0x00,0x68,0x04]])cm.append([[0xFE,0x05,0x00,0x08,0xFF,0x00,0x19,0xF7],[0xFE,0x05,0x00,0x08,0x00,0x00,0x58,0x07]])cm.append([[0xFE,0x05,0x00,0x09,0xFF,0x00,0x48,0x37],[0xFE,0x05,0x00,0x09,0x00,0x00,0x09,0xC7]])cm.append([[0xFE,0x05,0x00,0x0A,0xFF,0x00,0xB8,0x37],[0xFE,0x05,0x00,0x0A,0x00,0x00,0xF9,0xC7]])cm.append([[0xFE,0x05,0x00,0x0B,0xFF,0x00,0xE9,0xF7],[0xFE,0x05,0x00,0x0B,0x00,0x00,0xA8,0x07]])cm.append([[0xFE,0x05,0x00,0x0C,0xFF,0x00,0x58,0x36],[0xFE,0x05,0x00,0x0C,0x00,0x00,0x19,0xC6]])cm.append([[0xFE,0x05,0x00,0x0D,0xFF,0x00,0x09,0xF6],[0xFE,0x05,0x00,0x0D,0x00,0x00,0x48,0x06]])cm.append([[0xFE,0x05,0x00,0x0E,0xFF,0x00,0xF9,0xF6],[0xFE,0x05,0x00,0x0E,0x00,0x00,0xB8,0x06]])cm.append([[0xFE,0x05,0x00,0x0F,0xFF,0x00,0xA8,0x36],[0xFE,0x05,0x00,0x0F,0x00,0x00,0xE9,0xC6]])cm.append([[0xFE,0x05,0x00,0x10,0xFF,0x00,0x99,0xF0],[0xFE,0x05,0x00,0x10,0x00,0x00,0xD8,0x00]])cm.append([[0xFE,0x05,0x00,0x11,0xFF,0x00,0xC8,0x30],[0xFE,0x05,0x00,0x11,0x00,0x00,0x89,0xC0]])cm.append([[0xFE,0x05,0x00,0x12,0xFF,0x00,0x38,0x30],[0xFE,0x05,0x00,0x12,0x00,0x00,0x79,0xC0]])cm.append([[0xFE,0x05,0x00,0x13,0xFF,0x00,0x69,0xF0],[0xFE,0x05,0x00,0x13,0x00,0x00,0x28,0x00]])cm.append([[0xFE,0x05,0x00,0x14,0xFF,0x00,0xD8,0x31],[0xFE,0x05,0x00,0x14,0x00,0x00,0x99,0xC1]])cm.append([[0xFE,0x05,0x00,0x15,0xFF,0x00,0x89,0xF1],[0xFE,0x05,0x00,0x15,0x00,0x00,0xC8,0x01]])cm.append([[0xFE,0x05,0x00,0x16,0xFF,0x00,0x79,0xF1],[0xFE,0x05,0x00,0x16,0x00,0x00,0x38,0x01]])cm.append([[0xFE,0x05,0x00,0x17,0xFF,0x00,0x28,0x31],[0xFE,0x05,0x00,0x17,0x00,0x00,0x69,0xC1]])cm.append([[0xFE,0x05,0x00,0x18,0xFF,0x00,0x18,0x32],[0xFE,0x05,0x00,0x18,0x00,0x00,0x59,0xC2]])cm.append([[0xFE,0x05,0x00,0x19,0xFF,0x00,0x49,0xF2],[0xFE,0x05,0x00,0x19,0x00,0x00,0x08,0x02]])cm.append([[0xFE,0x05,0x00,0x1A,0xFF,0x00,0xB9,0xF2],[0xFE,0x05,0x00,0x1A,0x00,0x00,0xF8,0x02]])cm.append([[0xFE,0x05,0x00,0x1B,0xFF,0x00,0xE8,0x32],[0xFE,0x05,0x00,0x1B,0x00,0x00,0xA9,0xC2]])cm.append([[0xFE,0x05,0x00,0x1C,0xFF,0x00,0x59,0xF3],[0xFE,0x05,0x00,0x1C,0x00,0x00,0x18,0x03]])cm.append([[0xFE,0x05,0x00,0x1D,0xFF,0x00,0x08,0x33],[0xFE,0x05,0x00,0x1D,0x00,0x00,0x49,0xC3]])cm.append([[0xFE,0x05,0x00,0x1E,0xFF,0x00,0xF8,0x33],[0xFE,0x05,0x00,0x1E,0x00,0x00,0xB9,0xC3]])cm.append([[0xFE,0x05,0x00,0x1F,0xFF,0x00,0xA9,0xF3],[0xFE,0x05,0x00,0x1F,0x00,0x00,0xE8,0x03]])cm.append([[0xFE,0x0F,0x00,0x00,0x00,0x10,0x02,0xFF,0xFF,0xA6,0x64],[0xFE,0x0F,0x00,0x00,0x00,0x10,0x02,0x00,0x00,0xA7,0xD4]]) #需要将硬件RTU格式命令十六进制如 FE 05 00 00 FF 00 98 35,转成字节码形式即在前面加0x,变成数组形式[0xFE,0x05,0x00,0x00,0xFF,0x00,0x98,0x35]输送给硬件串口以实现指令过程。try:ser serial.Serial(COM3, 9600) #需要连接串口线后通过在硬件管理里查看串口的名字这里是COM3。except:print(open serial failed.)exit(1)cmd_sendcm[int(lu)][int(s)]sser.write(cmd_send)print(cmd_send)ser.close()转载于:https://www.cnblogs.com/yzs1013/p/7761835.html