3.3 Test IOC communication with the simulator
Verify the complete command and reply path: CA client, stringout record, StreamDevice, asyn TCP, simulator, and readback.
Complete Configure an IOC for TCP communication and Run a TCP echo simulator first. Open three Bash terminals on the same host with these roles and settings:
| Terminal | Role | Working directory | Environment |
|---|---|---|---|
| Terminal 1 | TCP echo simulator (9399) | jeonglee_Demo/simulator/ | No EPICS environment required |
| Terminal 2 | Compiled IOC (./st.cmd) | jeonglee_Demo/iocBoot/iocB46_182-jeonglee_Demo/ | source "$TREE/setEpicsEnv.bash" |
| Terminal 3 | CA and PVA client | Any directory | source "$TREE/setEpicsEnv.bash", export EPICS_CA_AUTO_ADDR_LIST=NO EPICS_CA_ADDR_LIST=127.0.0.1, export EPICS_PVA_AUTO_ADDR_LIST=NO EPICS_PVA_ADDR_LIST=127.0.0.1 |
In each EPICS terminal, set TREE to your installation path from
lesson 1.1 (such as
"$HOME/epics/1.5.0/debian-13/7.0.10") before running
source "$TREE/setEpicsEnv.bash".
Start the simulator and IOC
-
In terminal 1, start the simulator from
simulator/:./tcpserver.bash 9399 -
In terminal 2, run
source "$TREE/setEpicsEnv.bash", then start the IOC fromjeonglee_Demo/:cd iocBoot/iocB46_182-jeonglee_Demo ./st.cmdWait for
iocRun: All initialization complete. Enterdblat the IOC prompt. It must list:jeonglee:myoffice:Cmd-RB jeonglee:myoffice:Cmd -
In terminal 3, run
source "$TREE/setEpicsEnv.bash"and select local searches:export EPICS_CA_AUTO_ADDR_LIST=NO EPICS_CA_ADDR_LIST=127.0.0.1 export EPICS_PVA_AUTO_ADDR_LIST=NO EPICS_PVA_ADDR_LIST=127.0.0.1
Send commands and read replies
-
Send an identification query:
caput -c jeonglee:myoffice:Cmd "DEVICE_ID?" caget jeonglee:myoffice:Cmd-RBcaput -cwaits for record processing to complete, and the readback returnsDEVICE_ID?:Old : jeonglee:myoffice:Cmd New : jeonglee:myoffice:Cmd DEVICE_ID? jeonglee:myoffice:Cmd-RB DEVICE_ID? -
Send another query and read the reply through both CA and PVA:
caput -c jeonglee:myoffice:Cmd "STATUS?" caget jeonglee:myoffice:Cmd-RB pvxget jeonglee:myoffice:Cmd-RBBoth reads report
STATUS?with zero alarm severity:Old : jeonglee:myoffice:Cmd DEVICE_ID? New : jeonglee:myoffice:Cmd STATUS? jeonglee:myoffice:Cmd-RB STATUS? jeonglee:myoffice:Cmd-RB value string = "STATUS?" alarm.severity int32_t = 0 alarm.status int32_t = 0 alarm.message string = "" timeStamp.secondsPastEpoch int64_t = 1794424750 timeStamp.nanoseconds int32_t = 132968952 timeStamp.userTag int32_t = 0 display.description string = "Raw query readback"
Observe a lost connection
-
Stop the simulator in terminal 1 with Ctrl+C, then send another command from terminal 3:
caput -c jeonglee:myoffice:Cmd "AFTER_STOP" caget jeonglee:myoffice:Cmd.STAT jeonglee:myoffice:Cmd.SEVR caget jeonglee:myoffice:Cmd-RBCmdentersCOMM/INVALIDalarm state, whileCmd-RBretains the priorSTATUS?string:Old : jeonglee:myoffice:Cmd STATUS? New : jeonglee:myoffice:Cmd AFTER_STOP jeonglee:myoffice:Cmd.STAT COMM jeonglee:myoffice:Cmd.SEVR INVALID jeonglee:myoffice:Cmd-RB STATUS?In terminal 2, the IOC console logs the disconnected TCP port:
2026/11/11 11:19:10.630171 LocalTCPServer jeonglee:myoffice:Cmd connectToAsynPort: Can't connect to 127.0.0.1:9399: Operation now in progress 2026/11/11 11:19:10.630201 LocalTCPServer jeonglee:myoffice:Cmd: device LocalTCPServer 0 disconnectedA cached readback value alone does not prove that the device accepted a command after the connection dropped.
-
Restart the simulator in terminal 1:
./tcpserver.bash 9399asynretries a lost connection periodically, so reconnection can take up to 30 seconds. Resend from terminal 3 and check both the reply and the command alarm fields:caput -c jeonglee:myoffice:Cmd "RECOVERED" caget jeonglee:myoffice:Cmd-RB jeonglee:myoffice:Cmd.STAT jeonglee:myoffice:Cmd.SEVRWhile
Cmd-RBstill showsSTATUS?, repeat both commands every few seconds. Once reconnected,Cmd-RBupdates toRECOVEREDandCmdclears its alarm state toNO_ALARM:Old : jeonglee:myoffice:Cmd AFTER_STOP New : jeonglee:myoffice:Cmd RECOVERED jeonglee:myoffice:Cmd-RB RECOVERED jeonglee:myoffice:Cmd.STAT NO_ALARM jeonglee:myoffice:Cmd.SEVR NO_ALARM
Verification
Confirm that each successful readback equals the command just sent. To test an incorrect endpoint, change the startup’s TCP port to an unused port, restart the IOC, and observe the failed transaction. Restore 9399, restart, and verify another round trip.
Enter exit in the IOC terminal and stop the simulator with Ctrl+C.