PyRadmon install and set up on Raspberry Pi (Wheezy Raspbian)

More
4 years 1 month ago #818 by jnissen
I have activities this weekend after all. I may have some time this afternoon.

Please Log in or Create an account to join the conversation.

More
4 years 1 month ago #819 by ThibmoRozier

jnissen wrote: I have activities this weekend after all. I may have some time this afternoon.


Just give me a notification when you are able to. :)
I think I have most of my contact details within my profile.

Please Log in or Create an account to join the conversation.

More
4 years 1 month ago - 4 years 1 month ago #842 by ThibmoRozier
I really wish I had an option to show the raw data from the GMC, but maybe this will do.
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 = int(response[0]) & 0x3F
                lsb = int(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
Last edit: 4 years 1 month ago by ThibmoRozier.

Please Log in or Create an account to join the conversation.

More
4 years 1 month ago - 4 years 1 month ago #854 by jnissen
I can give this a try a bit later today. I have also been thinking about running "miniterm.py" on the BBB and manually entering in the commands and seeing what responses come back. If I can get that to work I will post the results.



UPDATE:

I was able to run miniterm on the BBB with the following command

debian@beaglebone:~/RadMon$ miniterm.py -b 57600 -p /dev/ttyUSB0 -e -D
--- Miniterm on /dev/ttyUSB0: 57600,8,N,1 ---
--- Quit: Ctrl+] | Menu: Ctrl+T | Help: Ctrl+T followed by Ctrl+H ---
<GETVER>>GMC-300Re 2.36
<GETCPM>>\x00\x18<GETCPM>>\x00\x16

I had ECHO on as well as the debug so I could see the data coming back after a command. As soon as the second ">>" is presented to the GMC unit it returns the data. I hit the enter key after the <GETVER>> or it would have been on the same line.

So the data appears to be returned but it's not ASCII that is for sure so it may be the handler in the python script is having a bit of difficulty.

I then submitted a bunch of commands and they seem to have some variable delay in the response. It would respond within milliseconds to as much as 1 second. The delay seems to be variable. Odd since I am manually submitting the commands but the response back is defiantly not consistent.

Here is an example of the returned data. I hit enter after each response so it would read better.
<GETCPM>>\x00\x13
<GETCPM>>\x00\x14
<GETCPM>>\x00\x15
<GETCPM>>\x00\x15
<GETCPM>>\x00\x14
<GETCPM>>\x00\x14
<GETCPM>>\x00\x15
<GETCPM>>\x00\x15
<GETCPM>>\x00\x15
<GETCPM>>\x00\x14
<GETCPM>>\x00\x13
<GETCPM>>\x00\x13
<GETCPM>>\x00\x12
<GETCPM>>\x00\x12
<GETCPM>>\x00\x13
<GETCPM>>\x00\x14
<GETCPM>>\x00\x14
<GETCPM>>\x00\x14
<GETCPM>>\x00\x16
<GETCPM>>\x00\x16
<GETCPM>>\x00\x16
<GETCPM>>\x00\x16
<GETCPM>>\x00\x16
<GETCPM>>\x00\x17



As for the latest code you added:
python PyRadmon.py
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:
        invalid literal for int() with base 10: ''
Exiting

Waiting and reap threads
Last edit: 4 years 1 month ago by jnissen.

Please Log in or Create an account to join the conversation.

More
4 years 4 weeks ago #906 by jnissen
OK I had some more time to play with this. I have it communicating with the GMC detector and the Beagle Bone Black fairly well. It ran at least 8 hours without any errors. I am not convinced that the thing is communicating outside since I do not see my count update on the site. Is there an easy way to see if the communication back to the main server is OK? Here is a standard response:
Waiting 30 seconds => geiger 1

Geiger sample => geiger 1:      CPM = 17        2015-03-19 02:07:38.516733
Geiger sample => geiger 1:      CPM = 20        2015-03-19 02:07:42.525041
Geiger sample => geiger 1:      CPM = 19        2015-03-19 02:07:46.535699
Geiger sample => geiger 1:      CPM = 18        2015-03-19 02:07:50.546573
Geiger sample => geiger 1:      CPM = 18        2015-03-19 02:07:54.557623
Geiger sample => geiger 1:      CPM = 19        2015-03-19 02:07:58.568534
Geiger sample => geiger 1:      CPM = 19        2015-03-19 02:08:02.580153
Average result => geiger 1:     CPM = 18        2015-03-19 02:08:02.580153

Connecting to server => geiger 1

Sending average sample => geiger 1: 18 CPM

Server response => geiger 1:  HTTP/1.1 200 OK

I see an OK so is that all I should see? How long does it need to run before the site updates and recognizes it?

Please Log in or Create an account to join the conversation.

More
4 years 4 weeks ago #908 by mw0uzo
I will check the logs to see if your user/pass are correct etc

Please Log in or Create an account to join the conversation.

Time to create page: 0.105 seconds
Powered by Kunena Forum