ents 2.3.2__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,56 @@
1
+ """
2
+ @brief testing advance trace receive in stm32
3
+ @file adv_trace.py
4
+ @author Ahmed Hassan Falah
5
+ @date 2024-10-12
6
+ """
7
+
8
+ import serial
9
+ import serial.tools.list_ports
10
+
11
+
12
+ def sendToUART():
13
+ """
14
+ Sends the encoded configuration data via UART.
15
+ """
16
+ ser = None
17
+ try:
18
+ # Open the serial port
19
+ ser = serial.Serial(port="COM6", baudrate=115200, timeout=2)
20
+ # Send data (value 1)
21
+ data = bytes([1])
22
+ print(f"Sending: {data}")
23
+ ser.write(data)
24
+ print(
25
+ "________________________________________________________________________"
26
+ )
27
+ print(f"{data}")
28
+
29
+ # Read acknowledgment (1 byte)
30
+ ack = ser.read(1)
31
+ print(f"Received from STM32: {ack}")
32
+ print(
33
+ "________________________________________________________________________"
34
+ )
35
+
36
+ # Check acknowledgment
37
+ if ack == b"A":
38
+ print("Success")
39
+ elif ack == b"N":
40
+ print("Error NACK")
41
+ return False
42
+ else:
43
+ print("Error")
44
+ return False
45
+
46
+ except serial.SerialException as e:
47
+ print(f"UART Error: {e}")
48
+ return False
49
+
50
+ finally:
51
+ if ser is not None:
52
+ ser.close()
53
+
54
+
55
+ if __name__ == "__main__":
56
+ sendToUART()