|
RF-Positioning-System V0.1
by Max Heinekamp
|
This class handles the SCPI communication with the instrument. It is responsible for parsing SCPI commands, sending responses, and managing errors. More...
#include <scpi.h>
Classes | |
| struct | SCPI_Error |
| Struct to represent an error in the SCPI error queue. More... | |
| struct | SCPIClient |
| struct | SessionCloseLog |
| class | SessionStream |
| Stream wrapper around a tracked SCPIClient's EthernetClient that transparently counts bytes transferred and timestamps last activity, without needing any changes to the vendored SCPI parser library (which only ever needs a plain Stream&). More... | |
Public Member Functions | |
| SCPI () | |
| Construct a new SCPI object. | |
| void | setup () |
| Set up the SCPI server and register all available commands. | |
| void | processEthernet () |
| Process incoming SCPI commands over Ethernet. | |
| void | processSerial () |
| Process incoming SCPI commands over Serial. | |
| void | PrintDebugInfo (Stream &interface) |
| Print debug information about the SCPI parser to the specified interface. | |
| void | logError (int code, const char *message) |
| Log an error message to the SCPI error queue, compliant with section 21.8 of the SCPI standard. | |
| const char * | getError () |
| Get the oldest error message from the error queue, compliant with section 21.8 of the SCPI standard. | |
| int | getPort () |
| Get the port number of the SCPI server. | |
| void | reinitEthernet () |
| Re-initialize the Ethernet stack (re-reads IP/MAC from flash, re-begins Ethernet and the SCPI server, and drops all tracked client sessions). Used to recover after a hardware reset. | |
| void | printSessionList (Stream &interface) |
| Print the live SCPI session table (DIAGnostic:SESSion:LIST?). | |
| void | printSessionLog (Stream &interface) |
| Print the session close-reason ring buffer (DIAGnostic:SESSion:LOG?). | |
| void | printSocketList (Stream &interface) |
| Print the raw state of all 8 W5500 hardware sockets, not just the ones tracked as SCPI sessions (DIAGnostic:SOCKet:LIST?). | |
| void | printSystemDiagnostics (Stream &interface) |
| Print system/reset health diagnostics (DIAGnostic:SYStem?). | |
| void | printAllHeaders (Stream &interface) |
| Print every registered SCPI command header, one per line (SYSTem:HELP:HEADers?). | |
| void | printHeaderSyntax (Stream &interface, const char *header) |
| Print syntax help for a single command header (SYSTem:HELP:SYNTax?). | |
Private Member Functions | |
| void | registerCommands () |
| Register SCPI commands from scpi_commands.h/cpp. | |
| void | logSessionClose (const SCPIClient &slot, const char *reason) |
Private Attributes | |
| EthernetServer * | scpi_server = nullptr |
| SCPI_Parser | my_instrument |
| SCPIClient | scpi_clients [MAX_SCPI_CLIENTS] |
| SessionCloseLog | sessionLog [SESSION_LOG_SIZE] |
| int | sessionLogHead = 0 |
| int | sessionLogCount = 0 |
| unsigned long | linkFlapCount = 0 |
| unsigned long | reinitCount = 0 |
| EthernetLinkStatus | lastLinkStatus = Unknown |
| bool | server_started = false |
| SCPI_Error | errorQueue [ERROR_QUEUE_SIZE] |
| int | errorHead = 0 |
| Points to the next free slot. | |
| int | errorTail = 0 |
| Points to the oldest error. | |
| int | errorCount = 0 |
| Tracks number of stored errors. | |
| bool | queueOverflow = false |
| Tracks if queue overflowed. | |
| int | port = 0 |
| Store SCPI port number at time of initialization. | |
Static Private Attributes | |
| static const int | MAX_SCPI_CLIENTS = 4 |
| static const int | SESSION_LOG_SIZE = 16 |
This class handles the SCPI communication with the instrument. It is responsible for parsing SCPI commands, sending responses, and managing errors.
The SCPI class uses the Vrekrer SCPI parser library to handle SCPI commands. It also manages an error queue to store error messages and codes. The class is designed to work with both Ethernet and Serial communication interfaces. It registers all available SCPI commands and processes incoming commands from the specified interface.
| const char * SCPI::getError | ( | ) |
| int SCPI::getPort | ( | ) |
| void SCPI::logError | ( | int | code, |
| const char * | message ) |
|
private |
| void SCPI::printAllHeaders | ( | Stream & | interface | ) |
| void SCPI::PrintDebugInfo | ( | Stream & | interface | ) |
| void SCPI::printHeaderSyntax | ( | Stream & | interface, |
| const char * | header ) |
Print syntax help for a single command header (SYSTem:HELP:SYNTax?).
| interface | Stream interface to print to. |
| header | The header to look up (must match its full spelling as printed by printAllHeaders() — short forms are not resolved here). |
| void SCPI::printSessionList | ( | Stream & | interface | ) |
| void SCPI::printSessionLog | ( | Stream & | interface | ) |
| void SCPI::printSocketList | ( | Stream & | interface | ) |
| void SCPI::printSystemDiagnostics | ( | Stream & | interface | ) |
| void SCPI::processEthernet | ( | ) |
| void SCPI::processSerial | ( | ) |
|
private |
Register SCPI commands from scpi_commands.h/cpp.
| void SCPI::reinitEthernet | ( | ) |
| void SCPI::setup | ( | ) |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |