PSX Network Protocol |
|
The PSX Network ProtocolPSX exchanges messages with all clients (including the Router) using a simple, line-based, readable ASCII protocol. This means that nearly all programming languages in use can easily talk to PSX, and it is well possible to use a typing command line interface to monitor and interact with PSX. This tutorial assumes that your add-on program, or your manual command line interface, has been set up and connected to PSX (server or router). This procedure is described in the PSX Connection Protocol. To describe protocol message exchanges, this tutorial uses the following notational conventions:
Protocol Example
You see that the server gives you a connection ID (0) and its current version (10Alpha25b). You then upgrade the connection ID to a client name (Captain's Displays). This name upgrade is just so that the server end may show a more meaningful name than just 0 in certain lists. It is never actively used to make decisions by machines. The next exchange of Q variables is what the bulk of a PSX network connection is about. You receive a variable from PSX (code h54, value 887), then send a variable to PSX, receive three back, etc. Lastly, you send "exit" to PSX and the connection is broken. It is important to implement this message exchange in such a way that your add-on program can react to incoming messages all the time, irrespective of when they arrive, or in which order. This means that you must implement some form of event handler for incoming messages. It will never work if you expect certain strings and block your program until they arrive. This mode of operation is called asynchronous or non-blocking and most programming languages support it. You can make good use of the protocol that all messages are ended by a CR/LF byte sequence. Many programming languages allow you to set up the TCP connection in line buffering mode so that your add-on program is only notified of a complete message arrival, not the individual bytes. If you can set a buffer size, you should not go over the top. Typical PSX messages have a maximum length of about 60 bytes, and an average length of about 12. As long as your add-on program can handle them fast enough, you do not need to provide much more than a few Kb worth of buffering. Concerning whitespace: you should never include excess white space in the protocol, and neither should you remove whitespace. Especially leading and trailing spaces in the Qs variable messages are significant. More information about this is available in the section about the Qs variable category. PSX Variable CategoriesThis documentation is not authoritative. The official PSX documentation on the Aerowinx web site always takes precedence. PSX distinguishes three main variable categories: Qh, Qi, and Qs.
After you connect to a server, a continuous stream of Q variables will be pouring into your add-on program. You likely want to keep a list of the variables you are interested in, and store their latest value locally for reference when you need it. The variables you're not interested in can be simply ignored. To parse the incoming message lines, you can inspect the first character (Q). A Q always means that there will be a category (h, i, or s) and an equals sign (=) followed by a value. The value is always an integer when the category is h or i, and a string otherwise. If something does not match this pattern, notify some human operator and ignore the message. PSX Network ModesThis documentation is not authoritative. The official PSX documentation on the Aerowinx web site always takes precedence. Within the Qh and Qi categories, subclasses of variables exist that exhibit a common behaviour. These variables share a common network mode. PSX has the following network modes (in order of complexity):
Suggested next page: The PSX Lexicon >> |
© 2025 Jeroen Hoppenbrouwers All rights reserved, including those for text and data mining, AI training, potato stamps, and similar technologies. | For more information, mail to hoppie@hoppie.nl |