# Earthworm Modules:
sr2ew Overview

(last revised 25 July, 2018)

Introduction
sr2ew allows the Symmetric Research USBxCH family of low cost 24 bit data acquisition systems to send data to an Earthworm system running either Windows or Linux. USBxCH models with 4 and 8 channels are supported. Very accurate timestamping of the acquired data results when an optional GPS antenna is used with the USBxCH A/D. Timestamping using the PC system time set by NTP is also available.
sr2ew reads configuration information like EW ring and channel names from an Earthworm style .d configuration file and calls the Sr2EwPipeline batch file to start a USBxCH pipeline chain. Then it opens a named input pipe and waits to be connected to the acquisition pipeline. Once connected it reads incoming BIN packets, converts the data to Earthworm tracebuf2 format and writes it out to the specified EW ring. Configuration info for the pipeline utilities such as sampling rate is taken from the Sr2Ew.ini file.
In order to run sr2ew, you need a working Earthworm system, USBxCH A/D board, and SR USBxCH software for your OS available free from the Symmetric Research website www.symres.com. For accurate timing information, a GPS antenna is STRONGLY recommended.
Setup
Follow any instructions given in the official documentation to get Earthworm up and running.
The first step in adding USBxCH data is to install the USBxCH software. This can be done by unpacking the usbwin.zip or usblnx.tar file and running the included install script to copy the SR software to the \SR\USBXCH directory. Linux users should substitute /usr/local/SR/USBXCH for references to the \SR\USBXCH directory.
Then hook up the A/D hardware. Make sure it is working correctly by running the diagnostic program in the "\SR\USBXCH\Tools\01 Diag" directory. The acquisition programs in the "\SR\USBXCH\App - DVM" and "\SR\USBXCH\App - Scope" anddirectories can also help in checking out a new system.
To add an optional but highly recommended GPS antenna purchased from Symmetric Research, plug the 2.1mm power connector into the second 2.1mm jack on the back of the USBxCH and plug the DB25 connector on to the 25-pin Dshell digital input connector on the front right side of the USBxCH. Make sure it is working correctly by running the NmeaTime program in the "\SR\USBXCH\Tools\05 NmeaTime" directory which shows the received NMEA strings with the GPS information. When satellite lock is achieved, the red led will begin blinking and the $GPRMC string will show the letter A in the second field instead of the letter V.
Once Earthworm and the USBxCH are working on their own, it's time to get them working together. Copy the sr2ew.d and Sr2Ew.ini configuration files, the Sr2EwPipeline and Sr2EwPipelineKill batch files, and the sr2ew.desc file to the %EW_PARAMS% parameter directory. Then edit the config file settings so they are appropriate for your system. And make sure the batch files have execute permission.
At this time, you will probably also want to edit some additional Earthworm module configuration files to handle the USBxCH data that will be coming. This might include adding tanks for the USBxCH data in wave_serverV.d if the data is to be saved on the same computer or setting the USBxCH channels in export_scn.d if the data is to be exported to another computer. See the Earthworm example located in the \SR\USBXCH\Examples directory for some demo configurations.
In the beginning, it is probably best to use two separate command prompt windows. Don't forget to set up the Earthworm environment in the second window with ew_nt.cmd or ew_linux.bash. In the first, run startstop to start Earthworm. In the second, type "sr2ew" without the quotes to start the USBxCH acquiring and sending data. sr2ew configuration info is hardwired to come from "%EW_PARAMS%/sr2ew.d".
You can check the log files and run diagnostic programs like sniffring and sniffwave to help diagnose any problems. If something isn't going right, it is easy to stop sr2ew, modify its configuration file, and restart it without having to stop the rest of Earthworm. Once you've got your parameters set right, then go ahead and have startstop control sr2ew too.
Compiling
sr2ew is written in C and is compiled and linked using the standard Earthworm makefiles such as makefile.nt and makefile.unix. In order to run successfully, access to the USBxCH system software and hardware is required. This software, is included with every USBxCH purchase. It is also available for free download from the Symmetric Research website www.symres.com.
sr2ew has been designed so a single set of source code can service different operating systems. This is achieved by using conditional compilation to select OS specific code at compile time based on which SROS_xxx setting is defined. Valid options include SROS_WINDOWS and SROS_LINUX. Solaris is not available. However, the CustomPipeLib is provided as two separate files. So the makefiles are setup to copy the correct version to CustomPipeLib.c when compiling.
More Info
General questions about Earthworm are probably best answered by the official Earthworm User's forum on Google groups. But, if you have specific questions about sr2ew and its configuration parameters, please let us know at info@symres.com.

Module Index | sr2ew Commands