HTTP: read files from the web server
List the files of a Yaskawa controller with their description and read their text through its web server, without account and in any mode.
This page shows how to list the files of a Yaskawa Motoman controller and read their content through its web server, with the HTTP client of the SDK. It covers the YRC1000 and YRC1000micro controllers, and gives read only access: jobs, data files, parameters, logs.
What the HTTP client does
The controller has a web server on TCP port 80. The SDK reads the file lists and the files of this server, and gives you the names, the descriptions and the text of the files. It is the simplest way to read a file: no account, no remote mode, any mode of the controller.
| Need | HTTP | Other protocol |
|---|---|---|
| List the files of one type | Yes | FTP, High Speed Ethernet Server |
| Name and description of the data files | Yes | No |
| Read a text file (job, data, parameter) | Yes | FTP, High Speed Ethernet Server |
| Upload or delete a file | No | FTP, High Speed Ethernet Server |
| Binary files, CMOS backup | No | FTP, High Speed Ethernet Server |
Connect
Prerequisites
- The PC reaches the controller on TCP port 80.
- Nothing else: HTTP works in teach and in play mode, without the remote mode.
Enable HTTP
Set Http.Enable to true in ConnectParameters. Connect checks the address but does not send a request: the first method call is the first exchange.
| Parameter | Default | Meaning |
|---|---|---|
Http.Enable | false | Open the HTTP client |
Http.Port | 80 | TCP port of the web server |
Http.TimeoutMilliseconds | 5000 | Time to wait for the answer of a request |
List the files
GetFileList(fileExtension) lists the files of one type. Each FileDescription has the Name of the file and, for the data and parameter files, the Description given by the controller.
var robot = new YaskawaRobot();robot.Connect(parameters);// Jobs: the name onlyFileDescription[] jobs = robot.Http.GetFileList(FileExtension.JOB);// Data files: the name and the description given by the controllerforeach (FileDescription file in robot.Http.GetFileList(FileExtension.DAT))Console.WriteLine($"{file.Name}: {file.Description}"); // VAR.DAT: VARIABLE DATArobot.Disconnect();}
FileExtension | Files |
|---|---|
JOB | Jobs (.JBI) |
DAT | Data files: variables, alarm history, I/O names... (.DAT) |
CND | Condition files (.CND) |
PRM | Parameter files (.PRM), for example ALL.PRM |
SYS | System files (.SYS) |
LST | List files (.LST) |
CSV, LOG, TXT | Other text files |
On a YRC1000micro, GetFileList(FileExtension.DAT) returns VAR.DAT - VARIABLE DATA, ALMHIST.DAT - ALARM HISTORY DATA, IONAME.DAT - IO NAME DATA and more.
Read a file
GetFile(name) returns the text of a file. The SDK finds the folder of the file from its extension: TEST.JBI is a job, VAR.DAT a data file.
var robot = new YaskawaRobot();robot.Connect(parameters);// Text of a job: the folder is deduced from the extensionstring job = robot.Http.GetFile("TEST.JBI");// Variables, alarm history, parameters...string variables = robot.Http.GetFile("VAR.DAT");string alarmHistory = robot.Http.GetFile("ALMHIST.DAT");File.WriteAllText("TEST.JBI", job);robot.Disconnect();}
The text is the same as the file downloaded with FTP or with the High Speed Ethernet Server. A large file takes time: ALL.PRM (1.4 MB) takes about 13 s on a YRC1000micro, the same as with FTP. Increase TimeoutMilliseconds for large files.
Standalone client
HttpClient of the namespace UnderAutomation.Yaskawa.Http opens an HTTP client without YaskawaRobot. In a .NET project with implicit usings, System.Net.Http.HttpClient has the same name: write the full name, or add a using alias.
static void Main(){// An HTTP client without YaskawaRobot// Full name: System.Net.Http also has an HttpClient classvar client = new UnderAutomation.Yaskawa.Http.HttpClient();client.Connect("192.168.0.1", new HttpConnectParameters{Port = 80, // defaultTimeoutMilliseconds = 5000, // default});foreach (FileDescription file in client.GetFileList(FileExtension.PRM))Console.WriteLine(file);client.Close();}}
Reference
Methods of HttpClientBase :// Marks the client as disconnected.void Close();// Gets the content of a file from the robot controller. The file type is deduced from the file name extension (e.g. "PICK_JOB.JBI" queries /FGET_REQUEST/ROBOT/JOB/PICK_JOB.JBI).string GetFile(string fileName);// Gets the list of files of the specified type available on the robot controller.FileDescription[] GetFileList(FileExtension fileExtension);
Describes a file available on the robot controller.
| Member | Type | Description |
|---|---|---|
FileDescription() Constructor | ||
Description Property read only | string | Description of the file, if available. |
Name Property read only | string | File name including extension. |
ToString() Method | string | Returns the file name. |
Represents the file types available on a Yaskawa robot controller.
| Name | Value | Description |
|---|---|---|
CND | 2 | Condition files (.CND) |
CSV | 6 | CSV files (.CSV) |
DAT | 1 | Data files (.DAT) |
JOB | 0 | Job files (.JBI) |
LOG | 7 | Log files (.LOG) |
LST | 5 | List files (.LST) |
PRM | 4 | Parameter files (.PRM) |
SYS | 3 | System files (.SYS) |
TXT | 8 | Text files (.TXT) |
Connection parameters for HTTP communication with the robot controller.
| Member | Type | Description |
|---|---|---|
HttpConnectParameters() Constructor | Initializes a new instance of the HTTP connection parameters. | |
Port Property | int | Gets or sets the HTTP port number. Default: 80. |
TimeoutMilliseconds Property | int | Gets or sets the maximum time in milliseconds to wait for a response. Default: 5000ms. |
DEFAULT_PORT Field | int | Default HTTP port (80). |
DEFAULT_TIMEOUT_MILLISECONDS Field | int | Default timeout in milliseconds for HTTP requests (5000ms). |
What to read next
- FTP: upload, download and delete files.
- Transfer files and backups: which protocol to choose for each file task.