From 36db58fdd9d74876fee7c18bf5d5e2c7a827079a Mon Sep 17 00:00:00 2001
From: esarrey <eliott.sarrey@gmail.com>
Date: Thu, 8 Jun 2023 13:39:48 +0200
Subject: [PATCH] c sharp

---
 cshargapp.c   | 20 ++++++++++++++++++++
 hall_probe.py | 29 +++++++++--------------------
 2 files changed, 29 insertions(+), 20 deletions(-)
 create mode 100644 cshargapp.c

diff --git a/cshargapp.c b/cshargapp.c
new file mode 100644
index 0000000..251dfd9
--- /dev/null
+++ b/cshargapp.c
@@ -0,0 +1,20 @@
+using System;
+using System.Threading;
+using MagnetPhysik;
+
+namespace SensorApp
+{
+    class Program
+    {
+        static void Main(string[] args)
+        {
+            HallProbe hally = new HallProbe();
+
+            for (int i = 0; i < 100; i++)
+            {
+                Console.WriteLine(hally.Tesla);
+                Thread.Sleep(500);
+            }
+        }
+    }
+}
diff --git a/hall_probe.py b/hall_probe.py
index 813b49f..69b9812 100644
--- a/hall_probe.py
+++ b/hall_probe.py
@@ -1,25 +1,14 @@
-import ctypes
+import subprocess
 import time
-import sys
-import clr
-import platform
 
-print(platform.architecture())
+# Call the 32-bit application
+process = subprocess.Popen(['path/to/SensorApp.exe'], stdout=subprocess.PIPE, text=True)
 
-# Load the DLL
-sys.path.append(r"C:/Program Files (x86)/Magnet-Physik/USB Teslameter/")
-clr.AddReference("MagnetPhysik.Usb")
-
-from MagnetPhysik import HallProbe
-
-# Instantiate Hally - without knowing the exact method to instantiate an object, I am assuming it's 'HallProbe'
-hally = HallProbe() 
-
-
-# # Get Tesla value
-tesla = hally.Tesla 
-
-# # Loop to print Tesla value every half a second
+# Read and print output
 for x in range(100):
-    print("Field[T]: ", hally.Tesla)
+    output = process.stdout.readline().strip()  # strip() removes the newline
+    print("Field[T]: ", output)
     time.sleep(0.5)
+
+# Make sure the process has finished
+process.communicate()
-- 
GitLab