it's me again, Patrik. I just figured out that PC-BASIC does not emulate the machine ports for serial communication. I need to access the Line Control Register (&h3FB/&h2FB) with the OUT statement. Are you planning to implement this?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I have now tried to access the Line Control Register. Unfortunately, the measurement device I am using is connected to the computer via an USB serial adapter (this could not be changed). I assigned the port in the PCBASIC.INI: com2=PORT:COM37. For the open statement this works well, but not for the machine ports (0x3fb is not the machine port for the Line Control Register). I guess this is a more serious problem to solve.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Could you try OUT &H2FB? &H3FB is mapped to the LCR for COM1:, while &H2FB is mapped to the LCR of COM2:. Since you're attaching your physical port COM37 to PC-BASIC's COM2:, this is the address you should use.
For the avoidance of doubt, these are all emulated addresses, so it does not matter what the actual physical port or its address is; as long as the pyserial module can access it - which seems to be the case if the OPEN statement works correctly.
Rob
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Oh sorry, I actually tried &H2FB. I would like to set the break bit with the following code:
AD=1019:IF CP%=2 THEN AD=AD-256
BV=INP(AD):REM set break bit on UART
OUT AD,(BV OR 64):GOSUB 7100:REM wait for 1 second
OUT AD,(INP(AD) AND 191):REM reset break
CP% is 2 and the device is on com2=PORT:COM37. It seems that the measurement device does not receive the command for setting the break bit, since it does not respond correctly afterwards.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Thank for the code - that looks like it should work.
I'll check the PC-BASIC/pyserial code for the break, I can't find any obvious issues right now.
When you're saying it doesn't repond correctly, what does it do/do not do that it should be doing? The same register is used to set baudrate, parity, bytesize, and stopbits, so if any of those is incorrectly read or set in my code it may affect the device as well...
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
No, it is still not working. At first, INP(AD) is 3. Then, after entering OUT AD,(BV OR 64), INP(AD) is 4099. And then, after entering OUT AD,(INP(AD) AND 191) it is 3 again. The measurement device should do a reset after the break bit is set to 1, but this is not the case.
Patrik
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
OK, returning 4099 was definitely a bug which should now be fixed. I've alse made the code set the break signal fter the baudrate (the OUT command sets both) - perhaps reconfigurig the port dropped the break signal. Let me know if it helps.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi Patrik - does the break signal work correctly when using it through other programs than PC-BASIC? I'm asking because from searching on the internet it seems many USB serial adapters do not support the break correctly. Is there a way you can check/have checked that yours does work?
I realise the problem is probably within PC-BASIC (and progress is somewhat frustratingly slow on this issue) but since I don't have any serial port adapters or devices around the only way to debug this seems to be going back and forth.
Thanks!
Rob
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
OK, thanks for the info - I will try to debug the serial connection some more, I may be able to set up something with VirtualBox or get some USB serial gadget to play with. Thanks for helping catch some bugs, and do check in again in a while - perhaps I'll have found the issue!
Rob
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
View and moderate all "[CLOSED] General Discussion" comments posted by this user
Mark all as spam, and block user from posting to "Discussion"
Hi Rob,
it's me again, Patrik. I just figured out that PC-BASIC does not emulate the machine ports for serial communication. I need to access the Line Control Register (&h3FB/&h2FB) with the
OUT
statement. Are you planning to implement this?That is on my to-do list somewhere. I'll see if I can push it forward so we can do some testing on the serial port code.
View and moderate all "[CLOSED] General Discussion" comments posted by this user
Mark all as spam, and block user from posting to "Discussion"
I'd really appreciate if you could do that soon. Then I could test the program.
I have made a basic implementation of this in the source repo. I hope to push out another bugfix release next week that will include this.
15.08.2 is available now!
View and moderate all "[CLOSED] General Discussion" comments posted by this user
Mark all as spam, and block user from posting to "Discussion"
I have now tried to access the Line Control Register. Unfortunately, the measurement device I am using is connected to the computer via an USB serial adapter (this could not be changed). I assigned the port in the PCBASIC.INI:
com2=PORT:COM37
. For the open statement this works well, but not for the machine ports (0x3fb is not the machine port for the Line Control Register). I guess this is a more serious problem to solve.Could you try
OUT &H2FB
?&H3FB
is mapped to the LCR forCOM1:
, while&H2FB
is mapped to the LCR ofCOM2:
. Since you're attaching your physical portCOM37
to PC-BASIC'sCOM2:
, this is the address you should use.For the avoidance of doubt, these are all emulated addresses, so it does not matter what the actual physical port or its address is; as long as the pyserial module can access it - which seems to be the case if the
OPEN
statement works correctly.Rob
View and moderate all "[CLOSED] General Discussion" comments posted by this user
Mark all as spam, and block user from posting to "Discussion"
Oh sorry, I actually tried
&H2FB
. I would like to set the break bit with the following code:CP%
is 2 and the device is oncom2=PORT:COM37
. It seems that the measurement device does not receive the command for setting the break bit, since it does not respond correctly afterwards.Thank for the code - that looks like it should work.
I'll check the PC-BASIC/pyserial code for the break, I can't find any obvious issues right now.
When you're saying it doesn't repond correctly, what does it do/do not do that it should be doing? The same register is used to set baudrate, parity, bytesize, and stopbits, so if any of those is incorrectly read or set in my code it may affect the device as well...
One more thing - what value do you get for
BV
?I made some changes to the serial code at commit
506a92fd
- not sure if it helps with this issue but give it a try.Rob
View and moderate all "[CLOSED] General Discussion" comments posted by this user
Mark all as spam, and block user from posting to "Discussion"
No, it is still not working. At first,
INP(AD)
is 3. Then, after enteringOUT AD,(BV OR 64)
,INP(AD)
is 4099. And then, after enteringOUT AD,(INP(AD) AND 191)
it is 3 again. The measurement device should do a reset after the break bit is set to 1, but this is not the case.Patrik
OK, returning 4099 was definitely a bug which should now be fixed. I've alse made the code set the break signal fter the baudrate (the
OUT
command sets both) - perhaps reconfigurig the port dropped the break signal. Let me know if it helps.Hi Patrik - does the break signal work correctly when using it through other programs than PC-BASIC? I'm asking because from searching on the internet it seems many USB serial adapters do not support the break correctly. Is there a way you can check/have checked that yours does work?
I realise the problem is probably within PC-BASIC (and progress is somewhat frustratingly slow on this issue) but since I don't have any serial port adapters or devices around the only way to debug this seems to be going back and forth.
Thanks!
Rob
View and moderate all "[CLOSED] General Discussion" comments posted by this user
Mark all as spam, and block user from posting to "Discussion"
The serial break works fine with DOSBox. Since this seems to be a bigger probelm, I now give it up. But thanks for your help!
Patrik
OK, thanks for the info - I will try to debug the serial connection some more, I may be able to set up something with VirtualBox or get some USB serial gadget to play with. Thanks for helping catch some bugs, and do check in again in a while - perhaps I'll have found the issue!
Rob
What does your timing loop in
GOSUB 7100
look like?If it's a
FOR
loop the problem may be that the timings of loops are not the same between GW-BASIC and PC-BASIC.