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

More
8 years 4 months ago #1735 by ThibmoRozier
Just uploaded Version 1.2, hope this fixes it for you.
Please do try to use the .pyc file, it's way better then raw source.
The following user(s) said Thank You: matthieu

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

More
8 years 4 months ago #1736 by matthieu
Hi,
I keep having an encoding issue. This is what I get when running the .pyc:
Warning: Spoiler!

I just double-checked the sha256-checksums, but the file is unchanged during transfer to my raspberry.
SHA256: 614BD5ECC815683B6F5DC7DF2A5B4B0E11FF960515D448B18C888EA0DC87DA95

So I started with the .py file again ... aaaand it works.
FYI, here is the line from the config.txt:
# 2 - USB Device 0xccd:0x77: Audio (hw:1,0)
device=2
The weirdest thing I noticed: Even though I converted the py-file using dos2unix, the config.txt is also created with the wrong file endings and requires another dos2unix-run.

Best Regards,
Matthieu

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

More
8 years 4 months ago - 8 years 4 months ago #1737 by ThibmoRozier
I find that very weird, really.
Especially since I ask the system to create the file.
#!/usr/bin/python
<Snip>
import sys, os
<Snip>
"""
      Main loop is in while loop.
      Check if file exists, if not, create one and exit
    """
    if (os.path.isfile("config.txt") == 0):
        print "\tNo configuration file, creating default one.\r\n\t"

        try:
            f = open("config.txt", 'w')
            f.write("# Parameter names are not case-sensitive\r\n")
            f.write("# Parameter values are case-sensitive\r\n")
            f.write("user=test_user\r\n")
            f.write("password=test_password\r\n")
            f.write("# Port is usually /dev/ttyUSBx in Linux and COMx in Windows\r\n")
            f.write("serialport=/dev/ttyUSB0\r\n")
            f.write("speed=2400\r\n")
            f.write("# Protocols: demo, mygeiger, gmc, netio, audio\r\n")
            f.write("protocol=demo\r\n")
            f.write("# In case of audio, input the device number here, default is 0.\r\n")
            p = pyaudio.PyAudio()

            # For each audio device, determine if is an input or an output and add it to the appropriate list and dictionary
            for i in range (0, p.get_device_count()):
                dev = p.get_device_info_by_index(i)

                if dev['maxInputChannels'] > 0:
                    f.write("# " + str(i) + " - " + dev['name'] + " \r\n")
                else:
                    continue

            f.write("device=0\r\n")
            print "\tPlease open config.txt file using text editor and update configuration.\r\n"
        except Exception as e:
            print "\tFailed to create configuration file\r\n\t", str(e)
            logger.exception("Failed to create configuration file" + str(e))
        finally:
            time.sleep(1)
            p.terminate()
            f.close()

        # Set EOL for log
        logger.info("--------------------------------------- EOL ---------------------------------------\r\n")
        logging.shutdown()
        sys.exit(1)
    else:
<Snip>

I could replace all the "\r\n" parts with "..." + linesep though I doubt that will solve it.
I use Raspbian on my own Pi but... Eh.
Maybe it could be that this requires Python 2.7 and your pi runs 3.x?
Also about the compilation of the .pyc files I use the integrated compiler so it's odd how it would create windows file endings etc:
import sys
import py_compile

entry_point = sys.argv[1]
py_compile.compile(entry_point)

Maybe using "python ./PyRadmon.pyc" would solve some issues?
I think it would due to the compiled file not containing the shell variable that would start the python interpreter.

My Pi:
Warning: Spoiler!
Last edit: 8 years 4 months ago by ThibmoRozier.

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

More
8 years 4 months ago #1748 by matthieu

Maybe using "python ./PyRadmon.pyc" would solve some issues?

That really is the explanation.
The typical linux file ending is "\n". Everything else will cause weird behaviour. Python is one of the rare applications which doesn't care about the line ending. But that only works if you call python directly and give it the file to interprete as argument. Beeing a linux admin since years, I am used to just typing "./file" without naming the application. The first line contains the shebang which does exactly this job. But if the line ending is not what the system expects, it will fail to get the shebang.
I would suggest shipping "\n"-line endings for files that are meant to be used on linux environments. The vim editor I use also makes the config file look weird because every line ending is noted with a blue "^M".

Best Regards,
Matthieu

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

More
8 years 4 months ago #1750 by ThibmoRozier
Thanks for the reply, will add a special folder with VIM edited .py and Linux compiled .pyc files asap. :)

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

More
8 years 4 months ago - 8 years 4 months ago #1755 by matthieu
Hi,
the easiest way to convert the file AFAIK is the "dos2unix"-tool which is available through apt for raspberry pi.
But if you want to keep cross-OS compatibility, I guess it is easier to put a simple note somewhere.

Best Regards,
Matthieu
Last edit: 8 years 4 months ago by matthieu.

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

Moderators: Gamma-Man
Time to create page: 0.224 seconds
Powered by Kunena Forum
Everything's free. Please support us by considering a donation. Log in first!
Solar powered Raspberry Pi 4 server stats: CPU 34% Memory 12% Swap 9% CPU temp=59.9'C Uptime 3 Days