Skip to content
Snippets Groups Projects
Commit 36db58fd authored by esarrey's avatar esarrey
Browse files

c sharp

parent 05cd1d86
No related branches found
No related tags found
No related merge requests found
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);
}
}
}
}
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()
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment