Using OpcCmd Utility for OPC UA File Transfer: Difference between revisions
From OPC Labs Knowledge Base
Line 10: | Line 10: | ||
# Start the OpcCmd utility in interactive mode. The interactive mode is always in effect e.g. when you use ClickOnce, or when running the utility from QuickOPC Launcher/Start menu. In other cases, you need to use the <code>-i</code> (or <code>--interactive</code>) option on the command line.<br/><br/> | # Start the OpcCmd utility in interactive mode. The interactive mode is always in effect e.g. when you use ClickOnce, or when running the utility from QuickOPC Launcher/Start menu. In other cases, you need to use the <code>-i</code> (or <code>--interactive</code>) option on the command line.<br/><br/> | ||
# At the {{Style=label|OpcCmd>}} prompt, enter {{Style=keyboard|uaFileTransferClient}}, or shortened: {{Style=keyboard|uaftc}}. This command tells the utility that from now on, we will be accessing the File Transfer functionality of OPC UA. The programs responds with a confirmation of the command.<br/><br/>Subsequent commands are entered at the {{Style=label|uaFileTransferClient>}} prompt. You can enter <code>-?</code>, <code>-h</code> or <code>--help</code> (possibly preceded by the command name) at any time to obtain help for this prompt (or its commands).<br/><br/> | # At the {{Style=label|OpcCmd>}} prompt, enter {{Style=keyboard|uaFileTransferClient}}, or shortened: {{Style=keyboard|uaftc}}. This command tells the utility that from now on, we will be accessing the File Transfer functionality of OPC UA. The programs responds with a confirmation of the command.<br/><br/>Subsequent commands are entered at the {{Style=label|uaFileTransferClient>}} prompt. You can enter <code>-?</code>, <code>-h</code> or <code>--help</code> (possibly preceded by the command name) at any time to obtain help for this prompt (or its commands).<br/><br/> | ||
# In order to access a file | # In order to access a file that is represented by a standalone node in the server (not part of the OPC UA file system), enter {{Style=keyboard|1=getFileInfo opc.tcp://localhost:48030 "nsu=http://www.unifiedautomation.com/DemoServer/ ;s=Demo.Files.TextFile"}} (<code>getFileInfo</code> can be shortened to <code>gfi</code>). The node Id used in this command refers to a predefined node in the server which contains a demo text file. Subsequent commands are entered at the {{Style=label|fileInfo>}} prompt.<br/><br/> | ||
# Display the file properties by entering {{Style=keyboard|get}}.<br/>If this is the first operation made from this client on the server, you will most likely receive | # Display the file properties by entering {{Style=keyboard|get}}.<br/><br/> | ||
## The Unified Automation UA .NET SDK Bundle server will show the rejected client certificate on the "Rejected Certificates" tab of its window. On this tab, locate the rejected OpcCmd application certificate, right-click on it and select "Trust Permanently". | # The OpcCmd Utility will now ask you whether you want the client to trust the server certificate. Verify that that you have been presented with the right server server certificate, and if so, accept the certificate by pressing {{Style=keyboard|Y}} for "Yes".<br/>After the certificate is accepted, the <code>get</code> command proceeds. If OpcCmd is set to the "OPC compliance" mode, in which the secure connections are the default, and this is the first operation made from this client on the server, you will most likely receive file properties where the relevant values (such as file length, and last modified data) will be missing. This is caused by the fact that the server does not trust the client. In order to establish the trust: | ||
## The Unified Automation UA .NET SDK Bundle server will show the rejected client certificate on the "Rejected Certificates" tab of its window. On this tab, locate the rejected OpcCmd application certificate, right-click on it and select "Trust Permanently"; when asked, confirm the operation.<br/><br/> | |||
## Enter the {{Style=keyboard|get}} command again.<br/><br/> | ## Enter the {{Style=keyboard|get}} command again.<br/><br/> | ||
# {{Style=keyboard|saveTo --osFilePath c:\work\file1.txt}}<br/><br/> | # {{Style=keyboard|saveTo --osFilePath c:\work\file1.txt}}<br/><br/> | ||
# {{Style=keyboard|exit}}<br/><br/> | # {{Style=keyboard|exit}}<br/><br/> |
Revision as of 11:49, 17 May 2021
For general information about the OpcCmd tool, see Category:OpcCmd Utility.
Tutorial
If you execute the commands listed in the tutorial below, you will get an overview of basic operations that can be made with an OPC UA Server that provides OPC UA File Transfer model.
This tutorial works with Unified Automation UA .NET SDK Bundle server. You should be able to use the principles explained in this tutorial with other OPC UA servers that provide the File Transfer model, by modifying the relevant parameters used in the commands.
- Start the Unified Automation UA .NET SDK Bundle server, by typing start UaServerNET.exe at the operating system command prompt, when in the 'bin' directory of the Unified Automation UA .NET SDK Bundle.
- Start the OpcCmd utility in interactive mode. The interactive mode is always in effect e.g. when you use ClickOnce, or when running the utility from QuickOPC Launcher/Start menu. In other cases, you need to use the
-i
(or--interactive
) option on the command line. - At the OpcCmd> prompt, enter uaFileTransferClient, or shortened: uaftc. This command tells the utility that from now on, we will be accessing the File Transfer functionality of OPC UA. The programs responds with a confirmation of the command.
Subsequent commands are entered at the uaFileTransferClient> prompt. You can enter-?
,-h
or--help
(possibly preceded by the command name) at any time to obtain help for this prompt (or its commands). - In order to access a file that is represented by a standalone node in the server (not part of the OPC UA file system), enter getFileInfo opc.tcp://localhost:48030 "nsu=http://www.unifiedautomation.com/DemoServer/ ;s=Demo.Files.TextFile" (
getFileInfo
can be shortened togfi
). The node Id used in this command refers to a predefined node in the server which contains a demo text file. Subsequent commands are entered at the fileInfo> prompt. - Display the file properties by entering get.
- The OpcCmd Utility will now ask you whether you want the client to trust the server certificate. Verify that that you have been presented with the right server server certificate, and if so, accept the certificate by pressing Y for "Yes".
After the certificate is accepted, theget
command proceeds. If OpcCmd is set to the "OPC compliance" mode, in which the secure connections are the default, and this is the first operation made from this client on the server, you will most likely receive file properties where the relevant values (such as file length, and last modified data) will be missing. This is caused by the fact that the server does not trust the client. In order to establish the trust:- The Unified Automation UA .NET SDK Bundle server will show the rejected client certificate on the "Rejected Certificates" tab of its window. On this tab, locate the rejected OpcCmd application certificate, right-click on it and select "Trust Permanently"; when asked, confirm the operation.
- Enter the get command again.
- The Unified Automation UA .NET SDK Bundle server will show the rejected client certificate on the "Rejected Certificates" tab of its window. On this tab, locate the rejected OpcCmd application certificate, right-click on it and select "Trust Permanently"; when asked, confirm the operation.
- saveTo --osFilePath c:\work\file1.txt
- exit
- getDirectoryContents opc.tcp://localhost:48030 "nsu=http://www.unifiedautomation.com/DemoServer/ ;s=Demo.Files.FileSystem" --EndpointUser root:secret
- clear
- fileInfo MyTestFile.txt loadFrom --osFilePath c:\work\file1.txt
- fileInfos?
- createSubdirectory MyTestDirectory
- fileInfo MyTestFile.txt copyTo MyTestDirectory/CopyOfMyTestFile.txt
- browseTree
- fileInfo MyTestDirectory/CopyOfMyTestFile.txt delete
- browseTree