Menu

Machine ports for serial communication

Anonymous
2015-11-25
2015-12-30
  • Anonymous

    Anonymous - 2015-11-25

    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?

     
  • Rob Hagemans

    Rob Hagemans - 2015-11-25

    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.

     
    • Anonymous

      Anonymous - 2015-11-26

      I'd really appreciate if you could do that soon. Then I could test the program.

       
      • Rob Hagemans

        Rob Hagemans - 2015-11-27

        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.

         
        • Rob Hagemans

          Rob Hagemans - 2015-11-30

          15.08.2 is available now!

           
  • Anonymous

    Anonymous - 2015-12-07

    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.

     
  • Rob Hagemans

    Rob Hagemans - 2015-12-07

    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

     
    • Anonymous

      Anonymous - 2015-12-08

      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.

       
      • Rob Hagemans

        Rob Hagemans - 2015-12-08

        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...

         
        • Rob Hagemans

          Rob Hagemans - 2015-12-08

          One more thing - what value do you get for BV ?

           
  • Rob Hagemans

    Rob Hagemans - 2015-12-09

    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

     
    • Anonymous

      Anonymous - 2015-12-10

      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

       
      • Rob Hagemans

        Rob Hagemans - 2015-12-10

        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.

         
  • Rob Hagemans

    Rob Hagemans - 2015-12-12

    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

     
    • Anonymous

      Anonymous - 2015-12-17

      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

       
      • Rob Hagemans

        Rob Hagemans - 2015-12-17

        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

         
  • Rob Hagemans

    Rob Hagemans - 2015-12-30

    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.

     
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.