Closed Danitegue closed 2 years ago
PC-Basic's COMDevice._parse_params()
arbeitet mit bytes
, die Serial
-API will da aber Zeichenketten (str
) haben.
What were the values of CP$
, COMBR$
and COMSET$
when the error occurred?
b'CP$': b'$'[b'01adf6' b'1'] b'COMBR$': b'$'[b'05cc24' b':1200'] b'COMSET$': b'$'[b'12b024' b',n,8,1,rs,ds,cs,cd']
One possible solution I have found, is simply replace the line 104 of ports.py, function _parse_params():
from:
parity = parity or b'E'
to:
parity = parity.decode('utf8') or 'E'
@Danitegue Thanks, that's consistent with what @Marrin suggested, that the issue is that PC-BASIC uses bytes
here while serial
uses str
. Probably a hangover from the port to Python 3. I think it's OK as a workaround but the correct thing to do would probably be to change the internal parameter type in its entirety to use 'E'
etc. without prefix, so that it uses bytes
in Python 2 and str
in Python 3.
I need to check what it does in Python 2, while that's now end-of-lifed I have maintained compatibility with both versions so far; it'll definitely be dropped in 2.1 but it seems harsh to drop Python 2 support randomly now.
Hello Rob, I have created a pull request, with this problem solved: https://github.com/robhagemans/pcbasic/pull/153
This is a duplicate of #125, resolved on develop
branch.
Hello again Rob, I found this bug while trying the Brewer instrument software with your latest pip installed pcbasic version for python 3.x.
The launcher line I'm using is this one: Brewer C:\brw#072\Prog410>C:\Python38-32\python.exe -m pcbasic --interface=sdl2 --mount=Z:.,C:C:\,D: --current-device=Z --com1=PORT:COM14 --com2=stdio: --run=main.asc --quit=False -f=10 --shell="python C:\PCBREWER\Brw_functions.py" --debug=True --logfile=C:\Temp\pcbasic_brewer_log_072_20211029T205249Z.txt
PC-BASIC crash log
FATAL ERROR version 2.0.3 [v2.0.2-1-820-g6807f35bb 2020-09-26 16:10:49.837131] python 3.8.10 [32bit WindowsPE] platform Windows-10-10.0.19043-SP0 interface VideoSDL2, AudioSDL2 statement 9082 IF A$<>"p" THEN OPEN "com"+CP$+COMBR$+COMSET$ AS 7
files.py:94, open ports.py:70, open ports.py:261, set_params serialutil.py:336, parity ValueError: Not a valid parity: b'N'
This is a bug in PC-BASIC. Sorry about that. You can help improve PC-BASIC:
Please file a bug report, including this message and the steps you took just before the crash. Go to: https://github.com/robhagemans/pcbasic/issues
Please include the full crash log in your report. You can paste it from the clipboard or from the file at: C:\Users\Administrator\AppData\Roaming\pcbasic-2.0\crash-20211029-u3kf8wsg.log Traceback (most recent call last): File "C:\Python38-32\lib\site-packages\pcbasic\guard.py", line 51, in protect yield File "C:\Python38-32\lib\site-packages\pcbasic\main.py", line 118, in _run_session session.execute(cmd) File "C:\Python38-32\lib\site-packages\pcbasic\basic\api.py", line 91, in execute self._impl.execute(cmd) File "C:\Python38-32\lib\site-packages\pcbasic\basic\implementation.py", line 252, in execute self.interpreter.loop() File "C:\Python38-32\lib\site-packages\pcbasic\basic\interpreter.py", line 122, in loop self.parse() File "C:\Python38-32\lib\site-packages\pcbasic\basic\interpreter.py", line 112, in parse self.parser.parse_statement(ins) File "C:\Python38-32\lib\site-packages\pcbasic\basic\parser\statements.py", line 82, in parse_statement self._callbacksc File "C:\Python38-32\lib\site-packages\pcbasic\basic\devices\files.py", line 329, in open_ self.open(number, name, b'D', mode, access, lock, reclen) File "C:\Python38-32\lib\site-packages\pcbasic\basic\devices\files.py", line 94, in open new_file = device.open( File "C:\Python38-32\lib\site-packages\pcbasic\basic\devices\ports.py", line 70, in open self.set_params(speed, parity, bytesize, stop) File "C:\Python38-32\lib\site-packages\pcbasic\basic\devices\ports.py", line 261, in set_params self._serial.parity = parity File "C:\Python38-32\lib\site-packages\serial\serialutil.py", line 336, in parity raise ValueError("Not a valid parity: {!r}".format(parity)) ValueError: Not a valid parity: b'N' [...]
let me know if the full 48MB crash file is useful here, but I think this info is enough to find the bug
Best regards.