rewritten read-temp for parseability, added artisan patch

master
Dario Ernst 15 years ago
parent f5a2a89568
commit 88d4d3a4bd

@ -0,0 +1,121 @@
Index: artisan.py
===================================================================
--- artisan.py (revision 650)
+++ artisan.py (working copy)
@@ -95,7 +95,10 @@
from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg as FigureCanvas
from matplotlib.backends.backend_qt4agg import NavigationToolbar2QTAgg as NavigationToolbar
import matplotlib as mpl
-
+
+import subprocess
+import re
+
platf = unicode(platform.system())
@@ -283,14 +286,15 @@
"EXTECH 421509",
"Omega HH802U",
"Omega HH309",
- "NONE",
+ "NONE",
"+ArduinoTC4",
"TE VA18B",
"+309_34",
"+FUJI DUTY %",
"Omega HHM28[6]",
"+204_34",
- "+Virtual"
+ "+Virtual",
+ "Ooku"
]
#extra devices
@@ -3523,7 +3527,8 @@
#apply sampling interval here
libtime.sleep(aw.qmc.delay/1000.)
-
+
+
#if using a meter (thermocouple device)
if aw.qmc.device != 18:
#read time, ET (t1) and BT (t2) TEMPERATURE
@@ -10971,7 +10976,8 @@
self.fujidutycycle, #22
self.HHM28, #23
self.K204_34, #24
- self.virtual #25
+ self.virtual, #25
+ self.OOKU #26
]
#temporary storage to pass values. Holds extra T3 and T4 values for center 309
@@ -11173,6 +11179,12 @@
return tx,t2,t1
+ def OOKU(self):
+ t2,t1 = self.OOKUtemperature()
+ tx = aw.qmc.timeclock.elapsed()/1000.
+ return tx,t2,t1
+
+
#multimeter
def HHM28(self):
val,symbols= self.HHM28multimeter() #NOTE: val and symbols are type strings
@@ -11779,6 +11791,31 @@
else:
return -1
+
+ def OOKUtemperature(self):
+ scriptpath = os.path.realpath(os.path.dirname(sys.argv[0]))
+ p = subprocess.Popen(["%s/read-temp"%scriptpath, "temp"], stdin=subprocess.PIPE, stdout=subprocess.PIPE, close_fds=True)
+ p.wait()
+ sout = p.stdout.read()
+
+ correct_readout = False
+ if "CORRECT READOUT" in sout:
+ correct_readout = True
+
+
+ if not correct_readout:
+ raise ValueError("Could not read temperature from external program, sorry.")
+ else:
+ regex = re.compile("(?m)^(?P<num>\d): (?P<dec>\d{0,4})\.(?P<mod>\d{2}).*$", re.M)
+ res = regex.findall(sout)
+
+ if len(res)>=2:
+ t1 = float( "%s.%s"%(res[0][1], res[1][2]) )
+ t2 = float( "%s.%s"%(res[1][1], res[1][2]) )
+
+ return t1,t2
+
+
def TEVA18Btemperature(self):
try:
@@ -13657,10 +13694,20 @@
aw.ser.timeout=1
message = "" #empty message especial device
+ elif meter == "Ooku":
+ aw.qmc.device = 26
+ message = QApplication.translate("Message Area","Device set to %1", None, QApplication.UnicodeUTF8).arg(meter)
+ st = ""
+ if aw.qmc.delay != 1000:
+ aw.qmc.delay = 1000
+ st += ". Sampling rate changed to 1 second"
+ message = QApplication.translate("Message Area","Device set to %1%2", None, QApplication.UnicodeUTF8).arg(meter).arg(st)
+
+
#set of different serial settings modes options
ssettings = [[9600,8,'O',1,1],[19200,8,'E',1,1],[2400,7,'E',1,1],[9600,8,'N',1,1],[19200,8,'N',1,1,],[2400,8,'N',1,1],[9600,8,'E',1,1]]
#map device index to a setting mode
- devssettings = [0,1,2,3,3,3,3,3,3,3,3,3,3,3,3,2,1,3,0,4,5,3,6,5,3,3] #0-25
+ devssettings = [0,1,2,3,3,3,3,3,3,3,3,3,3,3,3,2,1,3,0,4,5,3,6,5,3,3,3] #0-26
self.savedevicetable()
#init serial settings of extra devices

@ -46,7 +46,7 @@ int cnt, vid, pid;
pid = rawPid[1] * 256 + rawPid[0];
/* The following function is in opendevice.c: */
if(usbOpenDevice(&handle, vid, vendor, pid, product, NULL, NULL, NULL) != 0){
fprintf(stderr, "Could not find USB device \"%s\" with vid=0x%x pid=0x%x\n", product, vid, pid);
fprintf(stdout, "Could not find USB device \"%s\" with vid=0x%x pid=0x%x\n", product, vid, pid);
usage();
exit(1);
}
@ -59,14 +59,14 @@ int cnt, vid, pid;
#if 0
int retries = 1, usbConfiguration = 1, usbInterface = 0;
if(usb_set_configuration(handle, usbConfiguration) && showWarnings){
fprintf(stderr, "Warning: could not set configuration: %s\n", usb_strerror());
fprintf(stdout, "Warning: could not set configuration: %s\n", usb_strerror());
}
/* now try to claim the interface and detach the kernel HID driver on
* Linux and other operating systems which support the call. */
while((len = usb_claim_interface(handle, usbInterface)) != 0 && retries-- > 0){
#ifdef LIBUSB_HAS_DETACH_KERNEL_DRIVER_NP
if(usb_detach_kernel_driver_np(handle, 0) < 0 && showWarnings){
fprintf(stderr, "Warning: could not detach kernel driver: %s\n", usb_strerror());
fprintf(stdout, "Warning: could not detach kernel driver: %s\n", usb_strerror());
}
#endif
}
@ -78,16 +78,17 @@ int cnt, vid, pid;
int i=0;
cnt = usb_control_msg(handle, USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_ENDPOINT_IN, 100, value, index, buffer, sizeof(buffer), 5000);
if(cnt < 0){
fprintf(stderr, "\nUSB error in iteration %d: %s\n", i, usb_strerror());
fprintf(stdout, "\nUSB error in iteration %d: %s\n", i, usb_strerror());
}
rxValue = ((int)buffer[1] & 0xff) | (((int)buffer[0] & 0xff) << 8);
rxIndex = ((int)buffer[3] & 0xff) | (((int)buffer[2] & 0xff) << 8);
fprintf(stdout, "CORRECT READOUT");
fprintf(stdout, "0: %3d.%02d*C \n", rxValue/100, rxValue%100);
fprintf(stdout, "1: %3d.%02d*C \n", rxIndex/100, rxIndex%100);
cnt = usb_control_msg(handle, USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_ENDPOINT_IN, 101, value, index, buffer, sizeof(buffer), 5000);
if(cnt < 0){
fprintf(stderr, "\nUSB error in iteration %d: %s\n", i, usb_strerror());
fprintf(stdout, "\nUSB error in iteration %d: %s\n", i, usb_strerror());
}
rxValue = ((int)buffer[1] & 0xff) | (((int)buffer[0] & 0xff) << 8);
rxIndex = ((int)buffer[3] & 0xff) | (((int)buffer[2] & 0xff) << 8);
@ -109,15 +110,15 @@ int cnt, vid, pid;
cnt = usb_control_msg(handle, USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_ENDPOINT_IN, opcode, addr, value, buffer, sizeof(buffer), 5000);
if(cnt < 0){
fprintf(stderr, "\nUSB error in iteration %d: %s\n", i, usb_strerror());
fprintf(stdout, "\nUSB error in iteration %d: %s\n", i, usb_strerror());
}
rxIndex = ((int)buffer[1] & 0xff) | (((int)buffer[0] & 0xff) << 8);
fprintf(stderr, "request = 0x%04x\n", opcode);
// fprintf(stderr, "answer: opcode=0x%02x addr=0x%02x value=0x%04x (%i)\n", buffer[1],buffer[0],rxIndex,rxIndex);
fprintf(stderr, "answer: value=0x%04x (%i)\n", rxIndex,rxIndex);
// fprintf(stderr, "rxValue = 0x%04x value = 0x%04x\n", rxValue, addr);
// fprintf(stderr, "rxIndex = 0x%04x index = 0x%04x\n", rxIndex, value);
fprintf(stdout, "request = 0x%04x\n", opcode);
// fprintf(stdout, "answer: opcode=0x%02x addr=0x%02x value=0x%04x (%i)\n", buffer[1],buffer[0],rxIndex,rxIndex);
fprintf(stdout, "answer: value=0x%04x (%i)\n", rxIndex,rxIndex);
// fprintf(stdout, "rxValue = 0x%04x value = 0x%04x\n", rxValue, addr);
// fprintf(stdout, "rxIndex = 0x%04x index = 0x%04x\n", rxIndex, value);
} else if(strcasecmp(argv[1], "dbg") == 0) {
if(argc != 2) {
usage();
@ -135,14 +136,14 @@ int cnt, vid, pid;
rq = rqRefreshHasNew;
cnt = usb_control_msg(handle, USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_ENDPOINT_IN, rq[0], rq[1], rq[2], buffer, sizeof(buffer), 5000);
if(cnt < 0){
fprintf(stderr, "\nUSB error in iteration ?!?: %s\n", usb_strerror());
fprintf(stdout, "\nUSB error in iteration ?!?: %s\n", usb_strerror());
}
// check whether we have new
rq = rqHasNew;
cnt = usb_control_msg(handle, USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_ENDPOINT_IN, rq[0], rq[1], rq[2], buffer, sizeof(buffer), 5000);
if(cnt < 0){
fprintf(stderr, "\nUSB error in iteration ?!?: %s\n", usb_strerror());
fprintf(stdout, "\nUSB error in iteration ?!?: %s\n", usb_strerror());
}
rxIndex = ((int)buffer[1] & 0xff) | (((int)buffer[0] & 0xff) << 8);
@ -151,7 +152,7 @@ int cnt, vid, pid;
rq = rqAdvance;
cnt = usb_control_msg(handle, USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_ENDPOINT_IN, rq[0], rq[1], rq[2], buffer, sizeof(buffer), 5000);
if(cnt < 0){
fprintf(stderr, "\nUSB error in iteration ?!?: %s\n", usb_strerror());
fprintf(stdout, "\nUSB error in iteration ?!?: %s\n", usb_strerror());
}
rxIndex = ((int)buffer[1] & 0xff) | (((int)buffer[0] & 0xff) << 8);
@ -159,11 +160,11 @@ int cnt, vid, pid;
rq = rqGetNew;
cnt = usb_control_msg(handle, USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_ENDPOINT_IN, rq[0], rq[1], rq[2], buffer, sizeof(buffer), 5000);
if(cnt < 0){
fprintf(stderr, "\nUSB error in iteration ?!?: %s\n", usb_strerror());
fprintf(stdout, "\nUSB error in iteration ?!?: %s\n", usb_strerror());
}
rxIndex = ((int)buffer[1] & 0xff) | (((int)buffer[0] & 0xff) << 8);
if(rxIndex != 0 && (rxIndex & 0xff) != 0xff){
fprintf(stderr, "%c", rxIndex);
fprintf(stdout, "%c", rxIndex);
}
}
usleep(100);

Loading…
Cancel
Save