Эта страница является
переводом страницы
Telnet. Перевод выполнен на 100%.
Connecting to a remote server using Telnet
The example shows a process of creating a driver in iRidium Studio on the basis of AV & Custom Systems (TCP) driver.
documentation was last updated on 14.8.2023
To process the received data and/or control the equipment, you can use the AV_Custom_Systems_(TCP,_UDP,_RS232) driver. To implement it, you need the Iridium Studio installed on your PC and any Telnet server. In the example we will connect to the HK-Telnet server.
Create a user in HK-Telnet:
1 Launch HK-Telnet Server
2 Select the “Create User” option
3 Specify a username and password for the user
Connecting with the “Command Line” tool:
1 Launch the “Command Line” app
2 Enter the “telnet” command
3 Enter the “open” command and the IP address of the remote server you want to connect to
4 Specify a username and password of the created user
After a successful connection, it is possible to run commands from the terminal
Work in iRidium Studio:
1 Launch the iRidium Studio and create the AV & Custom Systems (TCP) project driver. In the properties of the driver set the Host - IP address of the server, Port - 23 to which you will perform authorization and send commands from the i3 pro app.
2 To perform authorization use JS methods with the Script Editor tool built into iRidium Studio. Create a new script in Studio and paste this code, in the ‘login’ and ‘password’ items specify the data of the user you created in the Telnet Server:
IR.AddListener(IR.EVENT_RECEIVE_TEXT, IR.GetDevice('AV_Device'), function(text)
{
IR.Log("text = " + text);
if (text.indexOf('Username') != -1)
{
IR.Log("login")
IR.GetDevice('AV_Device').Send(['login',13,10]);
} else if (text.indexOf('Password') != -1)
{
IR.Log("password")
IR.GetDevice('AV_Device').Send(['password',13,10]);
}
})
3 After entering all the input data, launch the project and test its functionality. If the data is correct, the logs will display a message indicating the user login (USERNAME = TestUser) and confirmation of the connection “Welcome to Hadi Kiamarsi TELNET Server” and the IP address.
Sending commands to the server from the i3 pro app:
1 Create 2 Button elements to send commands to the server. In this example, the commands “ping” and “tree” (viewing a list of all folders in the current directory) are considered.
2 Create a function for each button with the “Send” method of command execution
function ping(){
IR.GetDevice('AV_Device').Send(['ping iridi.com',13,10]);
};
function tree(){
IR.GetDevice('AV_Device').Send(['tree',13,10]);
}
3 As a result of running the commands in the i3 pro logs you get the following data