Differences
This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
weatherbox:gateway:gateway_simulation [2016/11/16 01:58] tbyers |
weatherbox:gateway:gateway_simulation [2021/09/19 21:59] (current) |
||
---|---|---|---|
Line 1: | Line 1: | ||
====== Gateway Simulation Module ====== | ====== Gateway Simulation Module ====== | ||
- | The "Gateway Simulation Module" is a means to test the ability of the Gateway to correctly handle the various types of packets. The current simulation module includes the following packets: Heartbeat, Apple, Cranberry, Dragonfruit, and Bad Packet. If you wish to add more packets, follow the instructions below under "Capturing New Packets." | + | The "Gateway Simulation Module" is a means to test the ability of the Gateway to correctly handle the various types of packets. The current simulation module includes the following packets: Heartbeat, Apple, Cranberry, Dragonfruit, and Bad Packet. If you wish to add more packets, follow the instructions below under "Adding New Packets." |
To test the Gateway with simulated packets, first download or clone the repository at https://github.com/scel-hawaii/data-gateway. For best results use a linux machine. Windows machines are incompatible. | To test the Gateway with simulated packets, first download or clone the repository at https://github.com/scel-hawaii/data-gateway. For best results use a linux machine. Windows machines are incompatible. | ||
---- | ---- | ||
- | |||
- | **Edited: 09/29/16** | ||
The following documentation denotes how to test packets with the packet_tester.py without hardware on a Linux machine. | The following documentation denotes how to test packets with the packet_tester.py without hardware on a Linux machine. | ||
Line 13: | Line 11: | ||
* See documentation regarding setup [[weatherbox:unified_software_team:Packet Tester | here]]\\ | * See documentation regarding setup [[weatherbox:unified_software_team:Packet Tester | here]]\\ | ||
* test_data.py (used for writing preset packet to serial) | * test_data.py (used for writing preset packet to serial) | ||
- | * socat (used for creating virtual serial ports) | + | * //socat// (used for creating virtual serial ports) |
+ | * more info on //socat// [[http://www.dest-unreach.org/socat/ | here]] | ||
- | **Step 1: Install socat with the following command** | + | **Step 1: Install //socat// with the following command** |
sudo apt install socat | sudo apt install socat | ||
- | **Step 2: Run socat with the following command** | + | **Step 2: Run //socat// with the following command** |
socat -d -d pty,link=./ttyV1,raw,echo=0 pty,link=./ttyV2,raw,echo=0 | socat -d -d pty,link=./ttyV1,raw,echo=0 pty,link=./ttyV2,raw,echo=0 | ||
Line 47: | Line 46: | ||
**Step 5: Congratulations you have successfully tested packets without hardware!** | **Step 5: Congratulations you have successfully tested packets without hardware!** | ||
---- | ---- | ||
- | ====== Socat Usage ====== | + | ====== Adding New Packets ====== |
+ | If at some point you need to add more packets to the simulation, here is how to do it. | ||
+ | **Prerequisites: You need to have a working box transmitting the packets you would like to capture to an XBee device connected to your computer via USB.** | ||
+ | |||
+ | **Step 1: After cloning the data-gateway repository, move to the "test" directory** | ||
+ | |||
+ | cd test | ||
+ | |||
+ | **Step 2: Open the fake_packet.py file with the editor of your choice and make sure the "first block" of code is not commented out and the "second block" of code is commented out, if that is not the case make it so** | ||
+ | |||
+ | {{ :weatherbox:gateway:gateway_test_code_2.png?300 |}} | ||
+ | |||
+ | **Step 3: Run fake_packet.py while a weatherbox is transmitting the packets you wish to replicate, and an XBee is connected to your computer.** | ||
+ | |||
+ | python fake_packet.py | ||
+ | |||
+ | **Step 4: Reopen fake_packet.py and make sure the "first block" is now commented out and the "second block" is not commented out** | ||
+ | |||
+ | {{ :weatherbox:gateway:gateway_test_code_1.png?300 |}} | ||
+ | |||
+ | **Step 5: Run fake_packet.py again** | ||
+ | |||
+ | python fake_packet.py | ||
+ | |||
+ | **Step 6: The packet is now in the packet_data file. Now you can add the values from this file to the test_data.py script following the format existing there** | ||
+ | |||
+ | **NOTE: This process should be improved** | ||
+ | |||
+ | ---- | ||
+ | ====== Socat Usage ====== | ||
+ | {{ :weatherbox:gateway:gateway_sim_diagram.png |}} | ||
+ | As shown in the diagram above, we are using //socat// to open virtual ports. One of the virtual ports is passed the packet data we would expect to be transmitted by a weatherbox. This data is passed to the virtual port by means of a pipe. This data is then passed to the second virtual port where it can then be accessed by the "Packet Collector" process. In our case this process is the packet_tester.py. | ||
---- | ---- |