Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

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:

TerminalRoleWorking directoryEnvironment
Terminal 1TCP echo simulator (9399)jeonglee_Demo/simulator/No EPICS environment required
Terminal 2Compiled IOC (./st.cmd)jeonglee_Demo/iocBoot/iocB46_182-jeonglee_Demo/source "$TREE/setEpicsEnv.bash"
Terminal 3CA and PVA clientAny directorysource "$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

  1. In terminal 1, start the simulator from simulator/:

    ./tcpserver.bash 9399
    
  2. In terminal 2, run source "$TREE/setEpicsEnv.bash", then start the IOC from jeonglee_Demo/:

    cd iocBoot/iocB46_182-jeonglee_Demo
    ./st.cmd
    

    Wait for iocRun: All initialization complete. Enter dbl at the IOC prompt. It must list:

    jeonglee:myoffice:Cmd-RB
    jeonglee:myoffice:Cmd
    
  3. 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

  1. Send an identification query:

    caput -c jeonglee:myoffice:Cmd "DEVICE_ID?"
    caget jeonglee:myoffice:Cmd-RB
    

    caput -c waits for record processing to complete, and the readback returns DEVICE_ID?:

    Old : jeonglee:myoffice:Cmd
    New : jeonglee:myoffice:Cmd          DEVICE_ID?
    jeonglee:myoffice:Cmd-RB       DEVICE_ID?
    
  2. 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-RB
    

    Both 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

  1. 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-RB
    

    Cmd enters COMM / INVALID alarm state, while Cmd-RB retains the prior STATUS? 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 disconnected
    

    A cached readback value alone does not prove that the device accepted a command after the connection dropped.

  2. Restart the simulator in terminal 1:

    ./tcpserver.bash 9399
    

    asyn retries 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.SEVR
    

    While Cmd-RB still shows STATUS?, repeat both commands every few seconds. Once reconnected, Cmd-RB updates to RECOVERED and Cmd clears its alarm state to NO_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.