VS-ECG Programming Guide (V1.0)

3.0 VSM004 Data Flow

VSM004 is an USB serial port device. It helps to simplify the complicated BLE protocol to several serial port commands

  •  scan
  •  connect
  •  disconnect
  •  BLE command write and data receive

Here is a simple communiucation protocol chart to make you understand the command and data flow.

VS-ECG will send serial com port command to VSM004 and VSM004 will help to translate the simple serial com commands to complicated BLE protocols and send the request data to VSH101.

After the VSH101 finished the request and the data will be sent back via BLE to VS Dongle.

3.1 Find VSM004 name

VSM004 is a serial port type device. You can eaily find it in UNIX type OS such as ubuntu or macOS. It will be realized as a file and located in /dev. It is quite easy for you to find it.

ubuntu 20.04

Please type the following instruction to your ubuntu terminal

$ ls /dev/ttyUSB*

You might get a result look like below. In this case there is only one device named /dev/ttyUSB0. It is the VSM004. Please remember the string we will use it in the later sections.If there are more than one device has the name with ttyUSBxxx, you just have to remove the VS Dongle out from your PC and check which one is disapearred and that is the dongle’s name in your system.

macOS
Please type the following instruction to your ubuntu terminal

$ ls /dev/cu.usbserial*

You might get a result look like below. In this case there is only one device named /dev/cu.usbserial-113430. It is the VSM004. Please remember the string we will use it in the later sections. If there are more than one device has the name with cu.Ausbserial-xxx, you just have to remove the VSM004 out from your PC and check which one is disapearred and that is the dongle’s name in your system.

3.3 VSM004 Code Download

 You can download the source code from link below

VS-ECG GitHub Source OR, visit https://github.com/juangjl/vs-ecg for more information.

$ git clone https://github.com/juangjl/vs-ecg.git

After download the code from VS-ECG git, you can find a example named VsDongle.  Enter the VsDongle folder.

3.4 Set VSM004 Name

After download the code, the next step is change the VS004 name in the config.txt file. Set the VSM004 name you find in the 3.2 section (ex: /dev/ttyUSB0)

$ vim data/config.txt

Then, make clean and make all to rebuild the example. Use ./script/start.sh to start the example.

$ make clean
$ make all
$ ./script/start.sh

After executing these instructions you might get a result like below.

VsDongle example issues two commands to Vsdongle, the first one is  read version and the second one is to set the local time to VSM004 Dongle. 

This example shows how to communicate with VSM004 via serial port. The next example will demenstrate how to connect with VSH101 with BLE.