diff --git a/cshargapp.c b/cshargapp.c new file mode 100644 index 0000000000000000000000000000000000000000..251dfd9a7d60eb0269e817b6e7fdae8d2ce57295 --- /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 813b49fea30f98f4cfbcd3ccb687a0c2691b7aee..69b9812f5c41abce41b95a406c2601e2d576d5c1 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()