(n.b. in this document, \n denotes a newline character and \r a carriage return)
The nsd protocol is TCP-based and line-oriented. By default, the nsd server binds to all network addresses and accepts connections on port 8336. The nsd prints no welcome banner when new clients connect. All commands are a single line of text. For any command, the server first returns a line indicating general success or failure:
200 OK\\r\\n
400 BAD REQUEST\\r\\n
Every client that is connected has a current "role" status. Initially, it is set to "Unknown." There are three other roles that may be assumed, with three different commands:
display to enter Display role eeg to enter EEG role control to enter Controller role
role to print out the current role for this client
status to print a table showing the client id numbers and roles for all
display status
200 OK 200 OK 1 clients connected 0:Display
setheader <EDFHeaderPacket>\n
setheader 0 26.01.0418.36.01768 NEUROSD -1 1 2 Elec 00 Elec 01 Active Electrode Active Electrode uV uV 0 0 1023 1023 0 0 1023 1023 HP: DC; LP: 49 Hz HP: DC; LP: 49 Hz 2048 2048 Reserved Reserved \n
Another option for EEG's alone is the data frame command, spelled '!':
! <packetCounter> <channelCount> <sample[0]> <sample[1]> ... \n
! 45 2 123 125
In order to view data, a Display role must be used. A Display can use the watch, unwatch, and getheader commands.
watch <clientIndex>
watch 0\n
unwatch <clientIndex>
In order to get the sampling and other header information, the command
getheader <clientIndex>
getheader 0\n
If a Display is watching an EEG, it will receive special messages whenever a new data frame comes. These messages will be single lines of the form:
! <clientIndex> <packetCounter> <channelCount> <sample[0]> <sample[1]> ... \r\n
This entire protocol is implemented in the "nsd" NeuroServer component, and parts are used by every NeuroServer compatible application. Example protocol traces are shown in the tests/common.rb source file.