当前位置:网站首页>[trio basic tutorial 16 from introduction to proficiency] UDP communication test supplement

[trio basic tutorial 16 from introduction to proficiency] UDP communication test supplement

2022-07-05 08:01:00 Changjiang houlang blog

Dear friends , We meet again , Respond to the needs of friends , Specifically right UDP Did the communication expansion test , Share with you !

Testing conditions :

System version :WIN7 64

Programming software :Motion Perfect V4.2.1

Udp Testing software :netassist

Controller firmware :MC4N ECAT V2.0290


The test conditions are cleared , We started testing .

Code up :

'===========================================================
'dim port number
DIM com_port AS INTEGER
DIM get_strinput AS STRING(255)
com_port=20
'===========================================================
'close port and init port
CLOSE#com_port
OPEN#com_port AS "dgram:192.168.0.255(8899)" FOR READ_WRITE
WA(50)
PRINT #com_port,"Hello world!"
WHILE TRUE
    IF KEY #com_port THEN
        WA(5)
        CHANNEL_READ(com_port,get_strinput)
        WA(5)
        PRINT #com_port,get_strinput
        WA(5)
        PRINT #5,get_strinput
    ENDIF
    
    WA(10)
WEND


Next , We are going to test the software on our upper computer



Be careful : Local IP The address is the address currently set by the computer network card

The local port number is consistent with the controller program port ,TRIO Of UDP The port number is consistent with the remote port number , So here we're going to set theta 8899.


Try running the program


Program sending and receiving communication is normal ....

Thank you for your support , If you don't understand, come to me in private ....

原网站

版权声明
本文为[Changjiang houlang blog]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/02/202202140547278054.html