AgIsoStack++ Documentation
repository·main·Indexed 18 days ago
https://github.com/open-agriculture/agisostack-plus-plusA free, open-source C++11 library implementing the ISO-11783 (ISOBUS) standard for agricultural machinery communication over CANbus networks. It provides a platform-independent interface for implementing Virtual Terminals (VT), Task Controllers (TC), Auxiliary Control (AUX-N), and ISOBUS Shortcut Buttons (ISB). The library includes hardware abstraction for various CAN controllers (such as SocketCAN and PEAK PCAN) and high-level APIs for heartbeat, guidance, and power maintenance messages.
What's inside AgIsoStack++
- The Network API is the core component of the AgIsoStack++ library used to achieve compliant communication on the ISOBUS network. It serves as the primary interface for interacting with ISOBUS protocols and managing network-level operations.
Overview of AgIsoStack++
mainAgIsoStack++ is a platform-independent, open-source C++11 library designed to implement the ISO-11783 (ISOBUS) standard for agricultural machinery communication over CANbus networks. It provides a transparent interface that allows developers to focus on application logic rather than the complexities of the ISOBUS standard.
Key capabilities include:
- Virtual Terminal (VT) Client: Implementation of the Universal Terminal.
- Auxiliary Control (AUX-N): Support for auxiliary functions.
- Task Controller (TC): Both Client and Server implementations.
- ISOBUS Shortcut Button (ISB): Support for shortcut functionality.
- NMEA 2000: Support for Fast Packet Protocol.
- Guidance & Speed: Common guidance and speed messaging.
- Hardware Abstraction: Drivers for many common CAN controllers.
Supported Platforms for AgIsoStack++
mainAgIsoStack++ is designed to accommodate various hardware, but official support for building from source is limited to the following platforms:
- Ubuntu Linux (Non-WSL)
- Raspberry Pi OS (Raspbian)
- RHEL
- Windows
- MacOS
- ESP32
Note on WSL: Windows Subsystem for Linux (WSL) is not supported because the WSL kernel does not support socket CAN by default. While recompiling the WSL kernel might enable socket CAN, it is not an officially supported use case.
What is the ISOBUS Shortcut Button (ISB)?
mainAn ISOBUS Shortcut Button (ISB) is a physical or logical button that an operator can press to simultaneously command all implements to stop their current operations, functioning similarly to an emergency stop.
In the context of the AgIsoStack++ library, the ISB interface handles the parsing and sending of the "Stop implement operations" message (associated with SPN 5140).
Key Requirements:
- Receiving: If your application performs implement operations, you are highly advised (and often required for ISOBUS certification) to receive this message so your application can transition to a safe state.
- UI Reflection: If you are using the ISB interface and have a VT (Virtual Terminal) object pool, you must reflect the ISB state on your home screen.
- Sending: Any control function connected to the implement bus may send this message at its discretion.
What is a Device Descriptor Object Pool (DDOP)?
mainThe Device Descriptor Object Pool (DDOP) is a collection of objects uploaded from an implement to a Task Controller during the connection process. It serves as the authoritative source of implement geometry and capabilities, describing things like the number of sections, section widths, and product types.
- TC Clients: Must create a DDOP to describe the implement to the TC.
- TC Servers: Receive DDOPs from client implements and must interpret them to understand the implement's capabilities.
What is the Task Controller (TC) and how does it work?
mainThe Task Controller (TC) is a core component responsible for recording and planning data. It acts as the interface for operators to schedule tasks for implements to execute, enabling automated precision for activities like precision farming.
Architecture
The Task Controller follows a client-server model, similar to the Virtual Terminal:
- Server: Responsible for scheduling tasks.
- Client: Responsible for executing the tasks scheduled by the server.
Data Logger (DL) Distinction
A
Control Functionthat is registered as a Task Controller but is specifically defined to perform data logging functionality is referred to as a Data Logger (DL).Overview of AgIsoStack++ ECU implementation patterns
mainAgIsoStack++ provides a framework for building ISOBUS Electronic Control Units (ECUs) that control agricultural implements (e.g., seed drills or sprayers). A typical implementation involves several layers:
- Hardware Interface: Implementing a CAN-based interface to communicate on the physical bus.
- Control Functions: Setting up internal functions to receive commands and external functions to command other modules.
- Virtual Terminal (VT) Client: Implementing a VT client to send an ISO Object Pool (IOP) file to a tractor's display, allowing the operator to interact with the implement via the cab screen.
- Task Controller (TC) Client: Implementing a TC client to receive tasking jobs (e.g., field maps or prescription data).
- Application Logic: Developing the core logic that uses the TC job and VT commands to drive the implement hardware.
Understand the AgIsoStack++ Architecture
mainThe ISOBUS module architecture is divided into three primary layers:
- Hardware API: Handles the CAN transceiver driver and raw CAN frames.
- Networking API: Manages Control Functions (listening to and sending data) and transport protocols for message handling.
- Application: The user-level code where you implement logic to handle received data and send outgoing messages.
This separation allows the stack to abstract away specific hardware implementations (like SocketCAN) from the high-level ISOBUS networking logic.
Understand the ISOBUS Task Controller (TC) role
mainA Task Controller (TC) is an ISO11783-10 standard control function used to log and control implement functions. It manages task data, including task boundaries, coverage maps, and geospatial status.
Key responsibilities of a TC include:
- Using geospatial data to plan and command variable rate prescription tasks.
- Providing section control to prevent over-application in already covered areas.
Communication between the TC and the implement follows a stateful protocol where the TC sends commands/requests and the implement sends status updates. AgIsoStack abstracts much of this communication logic.
How the Virtual Terminal (VT) architecture works
mainThe Virtual Terminal (VT), sometimes referred to as a Universal Terminal (UT), follows a client-server architecture to allow an operator to control various implements through a single interface.
- The Client: The application that determines what content is displayed. It typically runs on the implement.
- The Server: The application that displays the client's content. It typically runs on the tractor.
Because the client and server are separate applications, they are almost always hosted on separate devices.
How TP and ETP messages are received
mainThe callback mechanism used for standard CAN messages also handles multi-frame Transport Protocol (TP) and Extended Transport Protocol (ETP) messages.
If a message is sent via BAM (Broadcast Announce Message) and exceeds the standard single-frame size, the stack reassembles the frames and delivers the complete payload to your registered callback. This allows you to receive messages of any size and any PGN using the same interface used for single-frame messages.
How the Hardware Interface Works
mainThe
CANHardwareInterfaceclass provides a common queuing and threading layer for the CAN stack and its drivers. It ensures a consistent, safe order of operations and simplifies integration by making the consumption of the receive queue and protocol updates effectively single-threaded, reducing the need for expensive mutexing in the core stack.Threading Model
The hardware interface operates using two primary thread activities:
- Receive Thread: Runs a thread that continuously fills a receive queue. This ensures messages are captured from the hardware or socket promptly.
- Network Manager Periodic Thread: Runs a main periodic thread that executes the following three steps in order:
- Drain Receive Queue: Messages are processed on this thread by the network manager. Most application callbacks occur here.
- Main Update Routine: Executes the core protocol logic.
- Transmit Queue: Attempts to send messages from the transmit queue until a transmit operation fails.
This cycle repeats every few milliseconds.