PyRadmon install and set up on Raspberry Pi (Wheezy Raspbian)
- ThibmoRozier
- Offline
- Elite Member
8 years 10 months ago #1735
by ThibmoRozier
Replied by ThibmoRozier on topic PyRadmon install and set up on Raspberry Pi (Wheezy Raspbian)
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.
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.
8 years 10 months ago #1736
by matthieu
Replied by matthieu on topic PyRadmon install and set up on Raspberry Pi (Wheezy Raspbian)
Hi,
I keep having an encoding issue. This is what I get when running the .pyc:
I just double-checked the sha256-checksums, but the file is unchanged during transfer to my raspberry.
So I started with the .py file again ... aaaand it works.
FYI, here is the line from the config.txt: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
I keep having an encoding issue. This is what I get when running the .pyc:
Warning: Spoiler!
pi@raspberrypi:~ $ ./PyRadmon.pyc
./PyRadmon.pyc: line 1: $'\003\363\r': command not found
./PyRadmon.pyc: line 2: $'0\201\232Vc': command not found
./PyRadmon.pyc: line 3: Z: command not found
./PyRadmon.pyc: line 4: $'dd\002l\vZ\vdd\002l\fZ\fdd\002l\rZ\rdd\002l\016Z\016d\003Z\017e\002j\020d\004d\005d\006d\ad\bd': command not found
./PyRadmon.pyc: line 5: syntax error near unexpected token `('
./PyRadmon.pyc: line 5: `d
▒ejd
d d▒▒YZde
jfd▒▒YZdefd▒▒YZdefd▒▒YZdefd▒▒YZdefd▒▒YZ▒Zde
jfd
▒YZdd!d▒▒YZd▒Ze dkr▒e▒ndS("i▒▒▒▒(tdequeNs1.2.0filenamespyradmon_log.logfilemodetatformats4%(asctime)s - %(name)s - %(levelname)s - %(message)stdatefmts%d/%m/%Y %H:%M:%S %psPyRadmon (Audio)tconfigcBs>eZdZdZdZdZdZdZd▒d▒Z RSiiiiiicCs▒d|_d|_d|_d|_d|_d|_d|_|_|d|_'
PuTTYPuTTYPuTTYPuTTYPuTTYPuTTYPuTTYpi@raspberrypi:~ $ PuTTYPuTTYPuTTYPuTTYPuTTYPuTTYPuTTY
-bash: PuTTYPuTTYPuTTYPuTTYPuTTYPuTTYPuTTY: command not found
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
Best Regards,
Matthieu
Please Log in or Create an account to join the conversation.
- ThibmoRozier
- Offline
- Elite Member
8 years 10 months ago - 8 years 10 months ago #1737
by ThibmoRozier
Replied by ThibmoRozier on topic PyRadmon install and set up on Raspberry Pi (Wheezy Raspbian)
I find that very weird, really.
Especially since I ask the system to create the file.
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:
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:
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:
Last edit: 8 years 10 months ago by ThibmoRozier.
Please Log in or Create an account to join the conversation.
8 years 10 months ago #1748
by matthieu
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
Replied by matthieu on topic PyRadmon install and set up on Raspberry Pi (Wheezy Raspbian)
That really is the explanation.Maybe using "python ./PyRadmon.pyc" would solve some issues?
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.
- ThibmoRozier
- Offline
- Elite Member
8 years 10 months ago #1750
by ThibmoRozier
Replied by ThibmoRozier on topic PyRadmon install and set up on Raspberry Pi (Wheezy Raspbian)
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.
8 years 10 months ago - 8 years 10 months ago #1755
by matthieu
Replied by matthieu on topic PyRadmon install and set up on Raspberry Pi (Wheezy Raspbian)
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
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 10 months ago by matthieu.
Please Log in or Create an account to join the conversation.
Moderators: Gamma-Man
Time to create page: 0.289 seconds