Implement ISOBUS File Server (FS) Interface as a Personal Project

Introduce the ISOBUS File Server (FS) interface, compatible with ISO
11783-13. The implementation utilizes the kernel's existing CAN J1939
socket support.

For testing following setup can be used:
ip link add type vcan
ip l s dev vcan0 up

j1939acd -r 64-95 -c /tmp/1122334455667788.jacd 1122334455667788 vcan0 &
j1939acd -r 96-127 -c /tmp/1122334455667789.jacd 1122334455667789 vcan0 &

sleep 1

isobusfs-srv -i vcan0 -n 1122334455667788 -v vol1:/path/to/export/
isobusfs-cli -i vcan0 -n 0x1122334455667789 -m 0x1122334455667788 -I

Interactive mode currently support following commands:
exit - exit interactive mode
quit - exit interactive mode
help - show this help
dmesg - show log buffer
selftest - run selftest
ls - list directory
ll - list directory with long listing format
cd - change directory
pwd - print name of current/working directory
get - get file

Signed-off-by: Oleksij Rempel <linux@rempel-privat.de>
This commit is contained in:
Oleksij Rempel
2024-02-02 13:44:07 +01:00
committed by Oleksij Rempel
parent 6004c64f06
commit 42edaeaf52
30 changed files with 9750 additions and 0 deletions
+280
View File
@@ -0,0 +1,280 @@
#ifndef _ISOBUSFS_CMN_FH_H
#define _ISOBUSFS_CMN_FH_H
#include "isobusfs_cmn.h"
/**
* C.4.2.2 Move File Request
* struct isobusfs_move_file_request - Move File Request structure
* @fs_function: Function and command (1 byte)
* Bits 7-4: 0b0011 (Command - File Handling, see B.1)
* Bits 3-0: 0b0000 (Function - Move File, see B.2)
* @tan: Transaction number (1 byte) (see B.8)
* @file_handling_mode: File Handling Mode (1 byte) (see B.27)
* @src_path_name_length: Source Path Name Length (2 bytes) (see B.12)
* @dst_path_name_length: Destination Path Name Length (2 bytes) (see B.12)
* @src_path: Source Volume, Path, File and Wildcard Name (variable) (see B.34)
* @dst_path: Destination Volume, Path, File and Wildcard Name (variable) (see B.34)
*
* Transmission repetition rate: On request
* Data length: Variable
* Parameter group number: Client to FS, destination-specific
*/
struct isobusfs_move_file_request {
uint8_t fs_function;
uint8_t tan;
uint8_t file_handling_mode;
__le16 src_path_name_length;
__le16 dst_path_name_length;
/* Variable length data follows */
/* uint8_t src_path[]; */
/* uint8_t dst_path[]; */
};
/**
* C.4.2.3 Move File Response
* struct isobusfs_move_file_response - Move File Response structure
* @fs_function: Function and command (1 byte)
* Bits 7-4: 0b0011 (Command - File Handling, see B.1)
* Bits 3-0: 0b0000 (Function - Move File, see B.2)
* @tan: Transaction number (1 byte) (see B.8)
* @error_code: Error code (1 byte) (see B.9)
* 0: Success
* 1: Access denied
* 2: Invalid access
* 4: File, path or volume not found
* 6: Invalid given source name
* 7: Invalid given destination name
* 8: Volume out of free space
* 9: Failure during read operation
* 13: Volume is possibly not initialized
* 43: Out of memory
* 44: Any other error
* @reserved: Reserved, transmit as 0xFF (5 bytes)
*
* Transmission repetition rate: In response to Move File Request message
* Data length: 8 bytes
* Parameter group number: FS to client, destination-specific
*/
struct isobusfs_move_file_response {
uint8_t fs_function;
uint8_t tan;
uint8_t error_code;
uint8_t reserved[5];
};
/**
* C.4.3.1 Delete File Request
* struct isobusfs_delete_file_request - Delete File Request structure
* @fs_function: Function and command (1 byte)
* Bits 7-4: 0b0011 (Command - File Handling, see B.1)
* Bits 3-0: 0b0001 (Function - Delete File, see B.2)
* @tan: Transaction number (1 byte) (see B.8)
* @mode: File Handling Mode (1 byte) (see B.27)
* @path_len: Path Name Length (2 bytes) (see B.12)
* @path: Volume, Path, File, and Wildcard Name (variable length) (see B.34)
*
* Transmission repetition rate: On request
* Data length: Variable
* Parameter group number: Client to FS, destination-specific
*/
struct isobusfs_delete_file_request {
uint8_t fs_function;
uint8_t tan;
uint8_t mode;
__le16 path_len;
uint8_t path[];
};
/**
* C.4.3.2 Delete File Response
* struct isobusfs_delete_file_response - Delete File Response structure
* @fs_function: Function and command (1 byte)
* Bits 7-4: 0b0011 (Command - File Handling, see B.1)
* Bits 3-0: 0b0001 (Function - Delete File, see B.2)
* @tan: Transaction number (1 byte) (see B.8)
* @error_code: Error code (1 byte) (see B.9)
* 0: Success
* 1: Access denied
* 2: Invalid access
* 4: File, path, or volume not found
* 6: Invalid given file name
* 9: Failure during a write operation
* 13: Volume is possibly not initialized
* 43: Out of memory
* 44: Any other error
* @reserved: Reserved, transmit as 0xFF (5 bytes)
*
* Transmission repetition rate: In response to Delete File Request message
* Data length: 8 bytes
* Parameter group number: FS to client, destination-specific
*/
struct isobusfs_delete_file_response {
uint8_t fs_function;
uint8_t tan;
uint8_t error_code;
uint8_t reserved[5];
};
/**
* C.4.4.2 Get File Attributes Request
* struct isobusfs_get_file_attributes_request - Get File Attributes Request structure
* @fs_function: Function and command (1 byte)
* Bits 7-4: 0b0011 (Command - File Handling, see B.1)
* Bits 3-0: 0b0010 (Function - Get File Attributes, see B.2)
* @tan: Transaction number (1 byte) (see B.8)
* @pathname_len: Pathname Length (2 bytes) (__le16, see B.12)
* @pathname: Volume, Path and Filename (variable length) (see B.35)
*
* Transmission repetition rate: On request
* Data length: Variable
* Parameter group number: Client to FS, destination-specific
*/
struct isobusfs_get_file_attributes_request {
uint8_t fs_function;
uint8_t tan;
__le16 pathname_len;
uint8_t pathname[];
};
/**
* C.4.4.3 Get File Attributes Response
* struct isobusfs_get_file_attributes_response - Get File Attributes Response structure
* @fs_function: Function and command (1 byte)
* Bits 7-4: 0b0011 (Command - File Handling, see B.1)
* Bits 3-0: 0b0010 (Function - Get File Attributes, see B.2)
* @tan: Transaction number (1 byte) (see B.8)
* @error_code: Error code (1 byte) (see B.9)
* 0: Success
* 1: Access denied
* 2: Invalid access
* 4: File, path or volume not found
* 6: Invalid given name
* 11: Failure during a read operation
* 13: Volume is possibly not initialized
* 43: Out of memory
* 44: Any other error
* @attributes: File attributes (1 byte) (see B.15)
* @file_size: File size (4 bytes) (see B.26)
*
* Transmission repetition rate: In response to Get File Attributes Request message
* Data length: Variable
* Parameter group number: FS to client, destination-specific
*/
struct isobusfs_get_file_attributes_response {
uint8_t fs_function;
uint8_t tan;
uint8_t error_code;
uint8_t attributes;
__le32 file_size;
};
/**
* C.4.5.2 Set File Attributes Request
* struct isobusfs_set_file_attributes_request - Set File Attributes Request structure
* @fs_function: Function and command (1 byte)
* Bits 7-4: 0b0011 (Command - File Handling, see B.1)
* Bits 3-0: 0b0011 (Function - Set File Attributes, see B.2)
* @tan: Transaction number (1 byte) (see B.8)
* @attributes: Set Attributes Command (1 byte) (see B.16)
* @name_length: Name length (__le16) (see B.12)
* @name: Path, File and Wildcard Name (n bytes) (see B.34)
*
* Transmission repetition rate: On request
* Data length: Variable
* Parameter group number: Client to FS, destination-specific
*/
struct isobusfs_set_file_attributes_request {
uint8_t fs_function;
uint8_t tan;
uint8_t attributes;
__le16 name_length;
uint8_t name[]; /* Variable length */
};
/**
* C.4.5.3 Set File Attributes Response
* struct isobusfs_set_file_attributes_response - Set File Attributes Response structure
* @fs_function: Function and command (1 byte)
* Bits 7-4: 0b0011 (Command - File Handling, see B.1)
* Bits 3-0: 0b0011 (Function - Set File Attributes, see B.2)
* @tan: Transaction number (1 byte) (see B.8)
* @error_code: Error code (1 byte) (see B.9)
* 0: Success
* 1: Access denied
* 4: File, path or volume not found
* 6: Invalid given name
* 8: Volume out of free space
* 9: Failure during a write operation
* 10: Media is not present
* 13: Volume is possibly not initialized
* 43: Out of memory
* 44: Any other error
* @reserved: Reserved, transmit as 0xFF (5 bytes)
*
* Transmission repetition rate: In response to Get File Attributes Request message
* Data length: Variable
* Parameter group number: FS to client, destination-specific
*/
struct isobusfs_set_file_attributes_response {
uint8_t fs_function;
uint8_t tan;
uint8_t error_code;
uint8_t reserved[5];
};
/**
* C.4.6.2 Get File Date & Time Request
* struct isobusfs_get_file_date_time_request - Get File Date & Time Request structure
* @fs_function: Function and command (1 byte)
* Bits 7-4: 0b0011 (Command - File Handling, see B.1)
* Bits 3-0: 0b0100 (Function - Get File Date & Time, see B.2)
* @tan: Transaction number (1 byte) (see B.8)
* @name_length: Path Name length (2 bytes) (see B.12)
* @name: Path, File and Name (n bytes) (see B.35)
*
* Transmission repetition rate: On request
* Data length: Variable
* Parameter group number: Client to FS, destination-specific
*/
struct isobusfs_get_file_date_time_request {
uint8_t fs_function;
uint8_t tan;
__le16 name_length;
uint8_t name[]; /* Variable length */
};
/**
* C.4.6.2 Get File Date & Time Response
* struct isobusfs_get_file_date_time_response - Get File Date & Time Response structure
* @fs_function: Function and command (1 byte)
* Bits 7-4: 0b0011 (Command - File Handling, see B.1)
* Bits 3-0: 0b0100 (Function - Get File Date & Time, see B.2)
* @tan: Transaction number (1 byte) (see B.8)
* @error_code: Error code (1 byte) (see B.9)
* 0: Success
* 1: Access denied
* 4: File, path, or volume not found
* 6: Invalid given name
* 10: Media is not present
* 11: Failure during read operation
* 13: Volume is possibly not initialized
* 43: Out of memory
* 44: Any other error
* @date: File date (2 bytes) (see B.24)
* @time: File time (2 bytes) (see B.25)
*
* Transmission repetition rate: In response to Get File Date & Time Request message
* Data length: 7 bytes
* Parameter group number: FS to client, destination-specific
*/
struct isobusfs_get_file_date_time_response {
uint8_t fs_function;
uint8_t tan;
uint8_t error_code;
__le16 date;
__le16 time;
};
#endif /* _LINUX_ISOBUS_FS_H */