Skip to content

Commit 8a6a913

Browse files
authored
data_acquisition.py: Added sync delay and documented under FAQ section of README.md.
* data_acquisition.py: Added sync delay and documented under FAQ section of README.md. --------- Signed-off-by: Rajasekhar Nikhita (DES DOS SWEE ESW EPE) <[email protected]>
1 parent f29febe commit 8a6a913

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

README.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,5 +88,22 @@ config = {
8888
}
8989
```
9090

91+
## FAQs
92+
93+
Q: I am encountering an error when trying to run the capture server, with messages such as __"Device not found or another error occurred: [WinError 10054] An existing connection was forcibly closed by the remote host."__
94+
95+
A: This error typically occurs when the client and server are not properly synchronized, and the client is already sending data before the server is ready to receive it. The current implementation uses a time.sleep(0.1) delay to account for this synchronization, which should cover most cases. However, if the delay is too short or too long for your specific sensor implementation, you may need to adjust this value accordingly.
96+
97+
Important Considerations:
98+
99+
- When adjusting the delay value, keep in mind that print statements in the script can also introduce a small delay, which should be factored into your calculation.
100+
- Ensure that the delay value is set to a suitable duration to allow for proper synchronization between the client and server.
101+
102+
103+
Q: I am experiencing __duplicate timestamps__ when importing data to Studio.
104+
105+
A: Duplicate timestamps may occur when importing data to Studio if the sensor is changed without adjusting the delay value accordingly. To resolve this issue, ensure that the delay value in `data_acquisition.py` script is adjusted in accordance with your implementation to synchronize the server and client. This adjustment will prevent duplicate timestamps and ensure accurate data importation.
106+
107+
91108
## Contributing Guide
92109
Please do not hesitate to share your sensor integration with the community! Open a [Pull Request](https://github.com/Infineon/deepcraft-micropython-data-acquisition/pulls) with your `sensors/sensor_name.py` and an example configuration in the `README.md`. 🙌

data_acquisition.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44
from network_utils import connect_wifi
55
from tcp_server import create_server_socket
66
from sensors.pdm_pcm import PDM_PCM # swap this out for any other sensor
7+
import time
8+
9+
SYNC_DELAY = 0.1
710

811
def main(sensor):
912
ip = connect_wifi()
@@ -23,6 +26,7 @@ def main(sensor):
2326
sensor.read_samples(rx_buf)
2427
packet = struct.pack(full_format, *rx_buf)
2528
conn.sendall(packet)
29+
time.sleep(SYNC_DELAY)
2630
except OSError as e:
2731
print("Connection error:", e)
2832
finally:

0 commit comments

Comments
 (0)