PyRadmon install and set up on Raspberry Pi (Wheezy Raspbian)
9 years 8 months ago #781
by mw0uzo
Replied by mw0uzo on topic PyRadmon install and set up on Raspberry Pi (Wheezy Raspbian)
Ok let me check code...
Please Log in or Create an account to join the conversation.
- ThibmoRozier
- Offline
- Elite Member
9 years 8 months ago #782
by ThibmoRozier
Thanks man, I really appreciate it.
Replied by ThibmoRozier on topic PyRadmon install and set up on Raspberry Pi (Wheezy Raspbian)
Ok let me check code...
Thanks man, I really appreciate it.
Please Log in or Create an account to join the conversation.
9 years 8 months ago - 9 years 8 months ago #783
by mw0uzo
Replied by mw0uzo on topic PyRadmon install and set up on Raspberry Pi (Wheezy Raspbian)
Every 30s send:
serialport.Write("<GETCPM>>");
Here is my c# code in the serial data handler for converting the serial buffer returned:
Question:
- Have you & msb with 0x3F to mask off the top bits, this might be confusing the conversion as these bits can vary depending on model/firmware apparently
serialport.Write("<GETCPM>>");
Here is my c# code in the serial data handler for converting the serial buffer returned:
if (gqserialButton.Checked & indata.Length==2)
{
byte msb = (byte) (indata[0] & 0x3F);
byte lsb = (byte) (indata[1] & 0xFF);
ushort cpm = (ushort)((msb << 8) | lsb);
receivednumber = (float)cpm;
numberstring = cpm.ToString();
}
Question:
- Have you & msb with 0x3F to mask off the top bits, this might be confusing the conversion as these bits can vary depending on model/firmware apparently
Last edit: 9 years 8 months ago by mw0uzo.
Please Log in or Create an account to join the conversation.
9 years 8 months ago - 9 years 8 months ago #784
by jnissen
Replied by jnissen on topic PyRadmon install and set up on Raspberry Pi (Wheezy Raspbian)
Well it ran over night... Not sure it was reporting in correctly as I did not see the map update or the latest data show valid.
Here is the errors from the latest code snippets you provided.
Here is the errors from the latest code snippets you provided.
Reading configuration:
User name configured
Password configured
Serial port name configured
Serial port speed configured
Protocol configured
Device number configured
Protocol configured
Using GMC protocol for 1 => geiger 1
No samples in queue, waiting 5 seconds => geiger 1
Gathering data started => geiger 1
Initializing GMC protocol communication => geiger 1
Found GMC-compatible device, version => geiger 1: GMC-300Re 2.36
Please note data will be acquired once per 5 seconds => geiger 1
Exception in thread Thread-1:
Traceback (most recent call last):
File "/usr/lib/python2.7/threading.py", line 552, in __bootstrap_inner
self.run()
File "PyRadmon.py", line 164, in run
self.initCommunication()
File "PyRadmon.py", line 329, in initCommunication
print "Unit shows time as => geiger 1: ", unitTime, "\r\n"
UnboundLocalError: local variable 'unitTime' referenced before assignment
Unit shows time as => geiger 1: No samples in queue, waiting 5 seconds => geiger 1
No samples in queue, waiting 5 seconds => geiger 1
No samples in queue, waiting 5 seconds => geiger 1
No samples in queue, waiting 5 seconds => geiger 1
No samples in queue, waiting 5 seconds => geiger 1
Last edit: 9 years 8 months ago by jnissen.
Please Log in or Create an account to join the conversation.
- ThibmoRozier
- Offline
- Elite Member
9 years 8 months ago - 9 years 8 months ago #786
by ThibmoRozier
Genious... Bitwise and and bitwise or... Epic, Dan.
I just wish I had a bloody GMC to test it by myself but egh...
Got a code fix here... Fingers crossed.
And fixed the reference.
It stated `responce=""` where it should state `unitTime=""`
My bad. :/
Just one thing I really wonder about...
Why the Fredrick did this make it this annoying? O.o
The method used by MyGeiger is waaaaay easier..
Replied by ThibmoRozier on topic PyRadmon install and set up on Raspberry Pi (Wheezy Raspbian)
Every 30s send:
serialport.Write("<GETCPM>>");
Here is my c# code in the serial data handler for converting the serial buffer returned:
if (gqserialButton.Checked & indata.Length==2) { byte msb = (byte) (indata[0] & 0x3F); byte lsb = (byte) (indata[1] & 0xFF); ushort cpm = (ushort)((msb << 8) | lsb); receivednumber = (float)cpm; numberstring = cpm.ToString(); }
Question:
- Have you & msb with 0x3F to mask off the top bits, this might be confusing the conversion as these bits can vary depending on model/firmware apparently
Genious... Bitwise and and bitwise or... Epic, Dan.
I just wish I had a bloody GMC to test it by myself but egh...
Got a code fix here... Fingers crossed.
And fixed the reference.
It stated `responce=""` where it should state `unitTime=""`
My bad. :/
class gmc(baseGeigerCommunication):
def initCommunication(self):
print "Initializing GMC protocol communication => geiger 1\r\n"
# get firmware version
self.serialPort.flushInput()
self.serialPort.write("<GETVER>>")
# assume that device responds within 1s
time.sleep(1)
response=""
while (self.serialPort.inWaiting()>0 and self.stopwork==0):
response = response + self.serialPort.read()
# response=self.sendCommand("< GETVER >>")
if len(response)>0:
print "Found GMC-compatible device, version => geiger 1: ", response, "\r\n"
# get serial number
# serialnum=self.sendCommand("<GETSERIAL>>")
# serialnum.int=struct.unpack('!1H', serialnum(7))[0]
# print "Device Serial Number is: ", serialnum.int
# disable heartbeat, we will request data from script
self.serialPort.flushInput()
self.serialPort.write("<HEARTBEAT0>>")
# self.sendCommand("< HEARTBEAT0 >>")
print "Please note data will be acquired once per 5 seconds => geiger 1\r\n"
# update the device time
self.serialPort.flushInput()
self.serialPort.write("<GETDATETIME>>")
# assume that device responds within 1s
time.sleep(1)
unitTime=""
while (self.serialPort.inWaiting()>0 and self.stopwork==0):
unitTime = unitTime + self.serialPort.read()
# unitTime=self.sendCommand("< GETDATETIME >>")
time.sleep(0.5)# just to ensure all CPM bytes are in serial port buffer
print "Unit shows time as => geiger 1: ", unitTime, "\r\n"
# self.sendCommand("<SETDATETIME[" + time.strftime("%y%m%d%H%M%S") + "]>>")
# print "<SETDATETIME[" + time.strftime("%y%m%d%H%M%S") + "]>>"
else:
print "No response from device => geiger 1\r\n"
self.stop()
sys.exit(1)
def getData(self):
cpm=-1
response=""
try:
# wait, we want sample every 30s
for i in range(0,3):
time.sleep(1)
# send request
self.serialPort.flushInput()
self.serialPort.write("<GETCPM>>")
# assume that device responds within 1s
time.sleep(1)
while (self.serialPort.inWaiting()>0 and self.stopwork==0):
response = response + self.serialPort.read()
# response=self.sendCommand("< GETCPM >>")
# wait for data
time.sleep(0.5) # just to ensure all CPM bytes are in serial port buffer
if len(response)==2:
# convert bytes to 16 bit int
msb = bytes(response[0] & 0x3F)
lsb = bytes(response[1] & 0xFF)
cpm = int((msb << 8) | lsb)
elif len(response) > 2:
edata=""
for i in range(1,len(response)):
edata = edata + ord(response[0])*256+ord(response[i])
cpm = int( ( float(edata) / ( len(response) - 1 ) ) +0.5)
else:
edata=""
for i in range(1,len(response)):
edata = edata + ord(response[0])*256+ord(response[i])
print "Unknown response to CPM request, device is not GMC-compatible? => geiger 1\r\n"
print "Data recieved was: ",str(edata),"\r\n"
except Exception as e:
print "\r\nProblem in getData procedure (disconnected USB device?) => geiger 1:\r\n\t",str(e),"\r\nExiting\r\n"
self.stop()
sys.exit(1)
utcTime=datetime.datetime.utcnow()
data=[cpm, utcTime]
return data
Just one thing I really wonder about...
Why the Fredrick did this make it this annoying? O.o
The method used by MyGeiger is waaaaay easier..
Last edit: 9 years 8 months ago by ThibmoRozier.
Please Log in or Create an account to join the conversation.
9 years 8 months ago - 9 years 8 months ago #787
by mw0uzo
Replied by mw0uzo on topic PyRadmon install and set up on Raspberry Pi (Wheezy Raspbian)
Cool, hope it will be fixed now
Stuff like that tends to be done in firmware because its all low level asm. Using spare bits for adding in functions on top of older code etc. The and-or mask is a classic, ever wonder how 2d 'sprites' were plotted on top of backgrounds without a nasty rectangular block around them?
Stuff like that tends to be done in firmware because its all low level asm. Using spare bits for adding in functions on top of older code etc. The and-or mask is a classic, ever wonder how 2d 'sprites' were plotted on top of backgrounds without a nasty rectangular block around them?
Last edit: 9 years 8 months ago by mw0uzo.
Please Log in or Create an account to join the conversation.
Moderators: Gamma-Man
Time to create page: 0.252 seconds