
USR-N720-C1µÄSocketA×öTCP serverʾÀý
Ò»¡¢×ÊÁÏÏÂÔØ
USR-N720-C1˵Ã÷ÊéÏÂÔØÁ´½Ó£º/Download/1493.html
USR-N720-C1¹æ¸ñÊéÏÂÔØÁ´½Ó£º/Download/1494.html
MQTTfx Èí¼þ£¬¿ÉÒÔ°Ù¶ÈÏÂÔØ¡£
¶þ¡¢Ó²¼þÁ¬½Ó
1¡¢ËùÐèÎïÆ·
USR-N720-C1 ²úÆ· 1̨
12VµçÔ´ÊÊÅäÆ÷ 1¸ö
USB-RS485´®¿ÚÏß 1Ìõ
³¬ÎåÀàÍøÏß 1¸ù
±Ê¼Ç±¾µçÄÔ 1̨
2¡¢Ó²¼þÁ¬½Ó
USR-N720-C1µÄµÚÒ»¸ö485´®¿Ú£¬½ÓUSB-RS485´®¿ÚÏߣ¬´®¿ÚÏßµÄA½ÓA1£¬B½ÓB1¡£USB-RS485´®¿ÚÏßµÄUSB²åµ½µçÄÔUSB¿Ú£¬È»ºó²úÆ·½Ó12VµçÔ´ÊÊÅäÆ÷Éϵ硣
USR-N720-C1µÄÍø¿Ú£¬ÓÃÍøÏߺ͵çÄÔÖ±Á¬¡£
3¡¢²é¿´¶Ë¿Ú
µçÄÔ´ò¿ª¼ÆËã»ú£¬É豸¾ÓªÆ÷£¬µã»÷¶Ë¿Ú£¬²é¿´USR-N720-C1µÄUSB-RS485´®¿ÚÏßµÄCOM¿ÚºÅ£¬ÊÇCOM10¡£
4¡¢µçÄÔ±¾µØÍø¿¨ÉèÖÃ
µçÄÔ´ò¿ª¿ØÖÆÃæ°å£¬µã»÷¸ü¸ÄÊÊÅäÆ÷ÉèÖ㬵ã»÷ÓÐÏßÍø¿¨£¬ÓÒ»÷£¬µã»÷ÊôÐÔ£¬µã»÷IPv4£¬USR-N720-C1ĬÈÏIPÊÇ192.168.0.7£¬µçÄÔÓÐÏßÍø¿¨ÉèÖÃͬÍø¶ÎµÄ¾²Ì¬IP£¬192.168.0.201£¬×ÓÍøÑÚÂë255.255.255.0£¬Íø¹Ø192.168.0.1
Èý¡¢USR-N720-C1²ÎÊýÉèÖÃ
1¡¢µÇ¼ÍøÒ³
ä¯ÀÀÆ÷ÊäÈë192.168.0.7£¬µÇ¼¿Í‘ôÃûºÍÃÜÂ붼ÊÇadmin
2¡¢ÍøÂç²é¿´ÍøÂçÉèÖÃ
ÍøÒ³£¬µã»÷ÍøÂ磬¿ÉÒÔÇл»N720ÁªÍø·½Ê½¡£
3¡¢¶Ë¿Ú²é¿´´®¿Ú²ÎÊý
µã»÷¶Ë¿Ú£¬´®¿Ú£¬¿ÉÒԲ鿴´®¿Ú1ĬÈÏ´®¿Ú²ÎÊý£¬²¨ÌØÂÊÊÇ9600¡£
4¡¢Í¨ÐÅÉèÖ㬿ªÆôSocket
ÍøÒ³£¬µã»÷ͨÐÅ£¬µã»÷Socket£¬SocketAµÄSocketʹÄÜ¿ªÆô¡£
SocketģʽTCP server¡£
±¾µØ¶Ë¿ÚºÅ£¬Ìî20108¡£
µã»÷Ó¦ÓÃ&±£´æ¡£
5¡¢Íø¹ØÉèÖ㬿ªÆô±ßÔµ¼ÆËã
ÍøÒ³£¬µã»÷Íø¹Ø£¬µã»÷±ßÔµ¼ÆË㣬Íø¹ØʹÄÜ¿ªÆô£¬µã»÷±£´æµ±Ç°Ò³£¬¼ÌÐøÅäÖã¬×îºóÖØÆô¡£
6¡¢±ßÔµ¼ÆË㣬Êý¾Ý²É¼¯ÉèÖÃ
£¨1£©Ìí¼Ó´Ó»ú
µã»÷Êý¾Ý²É¼¯£¬µã»÷Ìí¼Ó´Ó»ú¡£
ÊäÈë´Ó»úÃû³ÆDevice1£¬ÐÒéÀàÐÍÑ¡ÔñModbus RTU£¬´®¿ÚÑ¡Ôñ´®¿Ú1£¬´Ó»úµØÖ·1£¬µã»÷±£´æ¡£
£¨2£©Ìí¼ÓÊý¾Ýµã
µã»÷Ìí¼ÓÊý¾Ýµã£¬ÏÈÌí¼Ó¼Ä´æÆ÷µØÖ·0µÄÊý¾Ýµã¡£
ÊäÈëÊý¾ÝµãÃû³Ænode0101£¬¼Ä´æÆ÷ÓÃ4£¬1£¬¶ÔÓ¦²É¼¯¼Ä´æÆ÷µØÖ·0µÄÊý¾Ý¡£µã»÷±£´æ¡£
µã»÷Ìí¼ÓÊý¾Ýµã£¬ÔÙÌí¼Ó¼Ä´æÆ÷µØÖ·1µÄÊý¾Ýµã¡£ÊäÈëÊý¾ÝµãÃû³Ænode0102£¬¼Ä´æÆ÷ÓÃ4£¬2£¬¶ÔÓ¦²É¼¯¼Ä´æÆ÷µØÖ·1µÄÊý¾Ý¡£µã»÷±£´æ¡£
7¡¢±ßÔµ¼ÆË㣬Êý¾ÝÉϱ¨ÉèÖÃ
£¨1£©Ìí¼Ó·Ö×é
µã»÷Êý¾ÝÉϱ¨£¬µã»÷Ìí¼Ó·Ö×é¡£
ͨµÀÑ¡ÔñSocketA£¬Ñ¡ÔñÖÜÆÚÉϱ¨¡£
Éϱ¨Ä£°å£º{"device01":{"node0101":"node0101","node0102":"node0102"},"time":"sys_local_time"}
device01¶ÔÓ¦´Ó»úÃû³Æ£¬node0101¶ÔÓ¦µÚÒ»¸öÊý¾ÝµãÃû³Æ£¬node0102¶ÔÓ¦µÚ¶þ¸öÊý¾ÝµãÃû³Æ¡£
µã»÷±£´æ¡£
8¡¢±£´æ£¬ÖØÆô
µã»÷±£´æµ±Ç°Ò³£¬µã»÷ÖØÐÂÆô¶¯¡£
ËÄ¡¢Êý¾Ý½ÓÊÕ²âÊÔ
1¡¢MODBUS SLAVE Èí¼þÉèÖÃ
£¨1£©µã»÷Setup£¬Slave ID´Ó»úµØÖ·ÓÃ1£¬Function¹¦ÄÜÂëÓÃ03£¬Address¼Ä´æÆ÷ÆðʼµØÖ·ÓÃ0£¬Quantity¼Ä´æÆ÷µØÖ·ÊýÁ¿ÓÃ2¡£
¾ÍÊÇÄ£Äâ´Ó»úµØÖ·1£¬²É¼¯2¸ö¼Ä´æÆ÷µØÖ·0¡¢¼Ä´æÆ÷µØÖ·1µÄÊý¾Ý¡£
£¨2£©µã»÷Connection,Ñ¡Ôñ´®¿Ú£¬¶ÔÓ¦USRËù½ÓUSB-RS485´®¿ÚÏßµÄCOM¿ÚºÅ£¬´®¿Ú²ÎÊýºÍUSR´®¿Ú²ÎÊý±£³ÖÒ»Ö¡£ ModeÑ¡ÔñRTU£¬Ä£ÄâMODBUS RTUÐÒé´®¿Ú¡£
2¡¢Êý¾Ý½ÓÊÕ²âÊÔ
´ò¿ªÍøÂçÖúÊÖ£¬×öTCP client£¬·þÎñÆ÷IPÌîN720µÄIP 192.168.0.7£¬·þÎñÆ÷¶Ë¿ÚÌî20108£¬µã»÷Á¬½Ó¡£
½¨Á¢Á¬½ÓÖ®ºó£¬MODBUS SLAVEÈí¼þÐ޸ļĴæÆ÷µØÖ·0µÄÊý¾Ý£¬¸ÄΪ10£¬¼Ä´æÆ÷µØÖ·1µÄÊý¾Ý£¬¸ÄΪ20¡£
°´ÕÕÉϱ¨ÖÜÆÚ£¬Éϱ¨Êý¾Ý´«Êäµ½ÍøÂçÖúÊÖÈí¼þ¡£
°´ÕÕ¸ñʽÏÔʾ£º
{"device01":{"node0101":10,"node0102":20},"time":"2024-11-21,15:57:22"}
±àдÈË£º½ðÖ¾·½ ±àдÈÕÆÚ£º2024-11-21
ÉóºËÈË£º½ðÖ¾·½ ÉóºËÈÕÆÚ£º2024-11-21
¶©Õý°æ±¾£ºV1.0 ¶©ÕýÄÚÈÝ£º³õ¸å