Skip to content

CANopen File Server

The CANlink mobile offers a local nonvolatile file storage that can be accessed by CANopen SDO. This functionality for example is used for providing ECU update files to the machine received from the DataPlatform. Please also refer to Transfer User File via the DataPlatform.

The following functions are available for data access via the SDO:

Function Code Option Description
wr ["]path name ["] Write in file (always_in_Append_mode)
del ["]path name["] Delete file or directory
rd ["]path name["] [-o n] [-l m] Read out of file
ls List file or directory
cd [["]path["]] [..] [] Change directory

The following functions are available following data access via CANopen:

Index Subindex Meaning Data Type Description
0x4444 0x01 Command String See function descriptions. Please be aware that the maximum accessible file path size is 253 characters.
0x4444 0x02 Data Domain See function descriptions
0x4444 0x03 Status U16 The following states are displayed: 0 = OK / IDLE
1 = WRITE
2 = READ
3 = LIST
65535= ERROR
0x4444 0x04 Available size U32 Memory space available on file system in bytes
0x4444 0x05 File size U32 Size of current file selected, in bytes
0x5402 0x01 Status U16 The following states are displayed: 0 = *.usr-file not completely available
1 = *.usr-file completely available

Note

The SDO client must wait until the file system status flag 0x4444 sub 0x03 reads 0x0000 - OK / IDLE after sending the delete file command before issuing any other SDO communication.

  • The device may not respond to the SDO requests while it’s deleting the file and thus generate an SDO timeout also for reading the file system status flag.
  • Do not issue any other SDO communication requests until the status reads OK / IDLE

Restrictions

Restrictions on the flash size and file storage using the file server.

Note

File or path names that contain a space must be placed in quotation marks.

Note

The available flash size for file storage is maximum of 110 MB.

Folder or file names should consist of the following characters:

  • letters (uppercase/lowercase)
  • numbers
  • (space)
  • _ (underscore)
  • - (hyphen)

For file names, a dot . is also accepted. However, it is also possible to create file names without a dot ..

Note

If a given path name starts with \, the path is considered as starting in the root folder.

In case that the path name does not start with \, the path is considered as starting within the current folder.

Note

Please be aware the filename ls.txt is reserved for the automatically generated listing file.

Function Description

The following sections describe the individual functions and structure of the respective commands.

When entering commands, pay attention to the correct spelling and notation.

If spaces are contained, the path and file input must be set in quotation marks. If no spaces are contained, the use of quotation marks is optional.

WR - Write

  • Structure of the command: wr "path\name"

If the wr command is written to the command object, the device checks whether a file with this name exists. If no file is available, a new one is created.

An error code appears in the status object if the file cannot be opened to be written to or an error occurs.

The current file size is displayed in the file size object. The data content can then be written in the data object.

After completing the write operation to the data object, the file is automatically closed and the command deleted.

Directories can also be created with this command.

Note

The wr command always works in append mode. To overwrite an existing file, delete all old files manually beforehand.

Note

For the wr command, the following rules must be considered:

  • When only creating a folder, the command must always end with \.
  • If no \ is provided, a file is created without an extension.
  • If no \ and no . is provided, a file is created without an extension

DEL - Delete

  • Structure of the command: del "path\name"

If the del command is written to the command object, the device checks for existing files with this name. If the file exists, it will be deleted.

An error code appears in the status object if the file cannot be deleted or an error occurs.

When the process is completed, the command is deleted.

Directories can also be deleted in this way.

RD - Read File

  • Structure of the command: rd "path\name" [-o n] [-l m]

If the rd command is written to the command object, the device checks for existing files with this name.

An error code appears in the status object if the file does not exist or an error occurs.

The file size object displays the size of the current file. The data content can be read out of the data object.

After completing the read operation from the Data object, the file is automatically closed, and the command deleted.

The following options are available with this command:

  • -o n - Offset: n bytes The read process starts at the byte-position specified. Decimal or hexadecimal values are possible.

  • -l m - Length: m bytes The number of bytes specified (maximum_till_the_end_of_the_file) is read out of the file. Decimal or hexadecimal values are possible. To specify hexadecimal value use the prefix 0x, for example 0xA.

Note

When using the rd command, it must be ensured that the order of the arguments is kept as shown in the example: rd "path\name" [-o n] [-l m].

LS - List file or directory

  • Structure of the command: ls

If the ls command is written to the command object, a file and directory list can be read out of the data object.

Directory names are identified by < and >. A line feed [CRLF] occurs after each entry.

When the read operation from the Data object is completed, the command is deleted.

The result of the ls command looks like this example:

Content of USER:
< . >
< .. >
ls.txt
< folder_name >
usrfile1.usr
usrfile2.usr
usrfile3.usr

CD - Change Directory

  • Structure of the command: cd ["path"], [..], []

If the cd command is written to the command object, the device checks whether a directory with this name exists. If a directory with this name exists, it is opened.

An error code appears in the status object if the directory does not exist or an error occurs.

When the process is completed, the command is deleted.

The following options are available with this command:

  • "path" - Change to the directory specified.

  • .. - Change to the directory level one level higher.

  • \ - Change to the root directory.