PyRadmon install and set up on Raspberry Pi (Wheezy Raspbian)
- ThibmoRozier
 - 
				
											 - Offline
 - Elite Member
 - 
				
			 
			
	
						10 years 8 months ago				#798
		by ThibmoRozier
	
	
		
			
				
sooo....
I made a veeeeeeeery basic self-tester.
Now I finally got an answer for you.
Selftest:
Now that makes it easier for me to fix the code.
This gives me an output like :
Then I apply this to the whole code and...
For as far as I can think of, this will be the code.
What did we learn from this:
Frameworks are to make your work easier, just keep it simple!
							
					
	
			
			 		
													
	
				Replied by ThibmoRozier on topic PyRadmon install and set up on Raspberry Pi (Wheezy Raspbian)			
			Seems we are fighting a data type issue. Perhaps if the data were considered binary can Python handle that? Bitwise logical operations are easy in assembly and C but seems this is difficult in Python. I must tell you I have little to no Python experience so I do appreciate the assistance.
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 Unit shows time as => geiger 1: No samples in queue, waiting 5 seconds => geiger 1 Problem in getData procedure (disconnected USB device?) => geiger 1: hex() argument can't be converted to hex Exiting Waiting and reap threads
sooo....
I made a veeeeeeeery basic self-tester.
Now I finally got an answer for you.
Selftest:
#!/usr/bin/python
import sys
import time
response = 0x01, 62
if len(response)==2:
    # convert bytes to 16 bit int
    msb = (response[0] & 0x3F)
    lsb = (response[1] & 0xFF)
    cpm = int((msb << 8) | lsb)
    print(msb, lsb, cpm)
sys.exit(0)Now that makes it easier for me to fix the code.
This gives me an output like :
>>> ================================ RESTART ================================
>>> 
(1, 62, 318)
>>> Then I apply this to the whole code and...
For as far as I can think of, this will be the code.
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 = (response[0] & 0x3F)
                lsb = (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 dataWhat did we learn from this:
Frameworks are to make your work easier, just keep it simple!
Please Log in or Create an account to join the conversation.
			
	
						10 years 8 months ago		 -  10 years 8 months ago		#799
		by jnissen
	
	
		
			
	
	
			 		
													
	
				Replied by jnissen on topic PyRadmon install and set up on Raspberry Pi (Wheezy Raspbian)			
			
				Ha ha! I will let you know how it works tonight. Need to get home and try it out.
Update... Not sure If I have something wrong but still see this error. I can send you my detector and BBB if that helps.			
					Update... Not sure If I have something wrong but still see this error. I can send you my detector and BBB if that helps.
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
Unit shows time as => geiger 1:
No samples in queue, waiting 5 seconds => geiger 1
Problem in getData procedure (disconnected USB device?) => geiger 1:
        unsupported operand type(s) for &: 'str' and 'int'
Exiting
Waiting and reap threads
		Last edit: 10 years 8 months ago  by jnissen.			
			Please Log in or Create an account to join the conversation.
- ThibmoRozier
 - 
				
											 - Offline
 - Elite Member
 - 
				
			 
			
	
						10 years 8 months ago				#800
		by ThibmoRozier
	
	
		
			
				
Maybe it'd be better to set-up a teamviewer session on a scheduled moment.
I am available in about 3 hours, and then for about 8 hour long.
Would be rather easy to fix these issues then.
							
					
	
			
			 		
													
	
				Replied by ThibmoRozier on topic PyRadmon install and set up on Raspberry Pi (Wheezy Raspbian)			
			Ha ha! I will let you know how it works tonight. Need to get home and try it out.
Update... Not sure If I have something wrong but still see this error. I can send you my detector and BBB if that helps.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 Unit shows time as => geiger 1: No samples in queue, waiting 5 seconds => geiger 1 Problem in getData procedure (disconnected USB device?) => geiger 1: unsupported operand type(s) for &: 'str' and 'int' Exiting Waiting and reap threads
Maybe it'd be better to set-up a teamviewer session on a scheduled moment.
I am available in about 3 hours, and then for about 8 hour long.
Would be rather easy to fix these issues then.
Please Log in or Create an account to join the conversation.
			
	
						10 years 8 months ago				#802
		by jnissen
	
	
		
			
	
	
			 		
													
	
				Replied by jnissen on topic PyRadmon install and set up on Raspberry Pi (Wheezy Raspbian)			
			
				Can not do anything at the moment. Family stuff tonight. I may have time later this week. In the mean time I am going to see if I can get the BBB to talk over WiFi.			
					
		The following user(s) said Thank You: ThibmoRozier 	
			Please Log in or Create an account to join the conversation.
			
	
						10 years 7 months ago				#813
		by Juzzie
	
	
		
			
					
Owner and operator of "southofhobart" monitoring stations.
					
	
			
			 		
													
	
				Replied by Juzzie on topic PyRadmon install and set up on Raspberry Pi (Wheezy Raspbian)			
			
				put that gmc in the recycling bin!!! aarrr!			
							Owner and operator of "southofhobart" monitoring stations.
Please Log in or Create an account to join the conversation.
- ThibmoRozier
 - 
				
											 - Offline
 - Elite Member
 - 
				
			 
			
	
						10 years 7 months ago				#815
		by ThibmoRozier
	
	
		
			
				
Maybe on Saturday?
Could do for me.
							
					
	
			
			 		
													
	
				Replied by ThibmoRozier on topic PyRadmon install and set up on Raspberry Pi (Wheezy Raspbian)			
			Can not do anything at the moment. Family stuff tonight. I may have time later this week. In the mean time I am going to see if I can get the BBB to talk over WiFi.
Maybe on Saturday?
Could do for me.
Please Log in or Create an account to join the conversation.
		Moderators: Gamma-Man	
		Time to create page: 0.254 seconds