Menu

OPEN/COM/INPUT statement

Anonymous
2015-11-23
2015-12-03
  • Anonymous

    Anonymous - 2015-11-23

    I run PC-BASIC releases 15.03.5 and 15.08.1 on a 64 bit Windows computer. I use the serial port to access a measurement device.
    With the 15.03.5 release, the command

    OPEN "COM1:9600,N,8,1" FOR RANDOM AS 1
    works well, but with the 15.08.1 release this leads to the output "Device timeout".

    An even bigger problem is the COM statement. The statement works with port 1, but not with port 2. For example, when I type

    COM(2) OFF
    the program quits unexpectedly (to try this out I assigned com1 and com2 in the PCBASIC.INI to the same port).

    The program also quits when I enter the command

    INPUT #1,S$,F!
    while the serial port open in #1 should output a string character and a float number.

    I hope you can help, thanks!
    Patrik

     
  • Rob Hagemans

    Rob Hagemans - 2015-11-23

    Hi Patrik, thanks for your report!

    I can reproduce the second issue, so that should be relatively easy to solve for the next minor release.

    For the other two issues, the problem is that I don't have a serial port on my computer so this may be a bit more difficult. The more information you can give, the better I can figure this out.

    For issue (1), is there a time delay before you get the Device timeout error or does it happen immediately? Do you know more about what your device expects to see and what signals it sends? I suspect the issue lies in the settings for the DSR/DTR pins on the serial port, but this is just a guess for now. Would you have a manual or any other information about the device?
    One thing to try might be to set a different timeout value or the DSR signal, with e.g.:
    OPEN "COM1:9600,N,8,1,DS4000" FOR RANDOM AS 1

    For issue (3), could you run PC-BASIC from the command line? If you do that, when it crashes, do you get any message? If so, please post it here, as this might tell me what the issue is.

    Thanks again!
    Rob

     
  • Rob Hagemans

    Rob Hagemans - 2015-11-23

    Issue (2) has been solved in the git repository, will include in next bugfix release.

     
  • Anonymous

    Anonymous - 2015-11-24

    Hi Rob,

    for issue (1), there is no time delay. The Device timeout error occurs immediately after entering the command. I tried other DSR settings, but the error still shows up. An other interesting thing is, that in the 15.03.5 release
    OPEN "COM1:9600,N,8,1,RS,CS,DS" FOR RANDOM AS 1
    works properly while in the 15.08.1 release, the program crashes (without error messages).
    The device I am testing the program with is a thermometer. You can have a look at the serial port specifications in chapter 7.1 of http://www.advindsys.com/Manuals/HartManuals/1502A.pdf

    For issue (3), there is no error message.

    Thanks,
    Patrik

     
    • Rob Hagemans

      Rob Hagemans - 2015-11-24

      Thanks for the information - I will investigate.

      One more thing: could you try to run issue (3) and that last crash with the options --debug --logfile=log.txt and post the contents of log.txt here? I'm hoping the error message may appear in the logfile.

       

      Last edit: Rob Hagemans 2015-11-24
  • Anonymous

    Anonymous - 2015-11-24

    Note that the command
    INPUT #1,S$,F!
    was executed in release 15.03.5 since in 15.08.1 I could not open the device. The logfile shows only:

    INFO: Falling back to video_ansi interface.
    WARNING: Failed to initialise sound. Sound will be disabled.
    DEBUG: Error on closing screen: global name 'logger' is not defined
    

    For the command
    OPEN "COM1:9600,N,8,1,RS,CS,DS" FOR RANDOM AS 1
    in release 15.08.1, the logfile shows

    INFO: Falling back to video_ansi interface.
    WARNING: Failed to initialise sound. Sound will be disabled.
    
    ERROR: Unhandled exception
    Traceback (most recent call last):
      File "C:\Documents and Settings\Rob\My Documents\pc-basic\packaging\windows\build\installer\out00-PYZ.pyz\pcbasic.__main__", line 168, in start_basic
      File "C:\Documents and Settings\Rob\My Documents\pc-basic\packaging\windows\build\installer\out00-PYZ.pyz\pcbasic.run", line 46, in start
      File "C:\Documents and Settings\Rob\My Documents\pc-basic\packaging\windows\build\installer\out00-PYZ.pyz\pcbasic.run", line 60, in run_once
      File "C:\Documents and Settings\Rob\My Documents\pc-basic\packaging\windows\build\installer\out00-PYZ.pyz\pcbasic.statements", line 155, in parse_statement
      File "C:\Documents and Settings\Rob\My Documents\pc-basic\packaging\windows\build\installer\out00-PYZ.pyz\pcbasic.statements", line 1113, in exec_open
      File "C:\Documents and Settings\Rob\My Documents\pc-basic\packaging\windows\build\installer\out00-PYZ.pyz\pcbasic.devices", line 80, in open_file
      File "C:\Documents and Settings\Rob\My Documents\pc-basic\packaging\windows\build\installer\out00-PYZ.pyz\pcbasic.ports", line 125, in open
      File "C:\Documents and Settings\Rob\My Documents\pc-basic\packaging\windows\build\installer\out00-PYZ.pyz\pcbasic.ports", line 394, in open
    TypeError: unsupported type for timedelta microseconds component: str
    
    DEBUG: Error on closing screen: global name 'logger' is not defined
    

    Maybe this helps for issue (1).

     
    • Rob Hagemans

      Rob Hagemans - 2015-11-24

      Thanks, that should be useful for debugging.

      Out of curiosity, I note that you use the text interface (video_ansi) - is that by choice or does the graphical interface not work for some reason?

      Rob

       
  • Anonymous

    Anonymous - 2015-12-01

    Hi Rob,

    thank you for the 15.08.2 release. It seems that issue (1) and (2) have been solved.
    However, the program still crashes when I type

    OPEN "COM2:9600,N,8,1,RS,DS,CS,CD" FOR RANDOM AS 1
    PRINT #1,"H"
    INPUT #1,IN$
    

    with the error message:

    ERROR: Unhandled exception
    Traceback (most recent call last):
    File "E:\pc-basic\packaging\windows\build\installer\out00-PYZ.pyz\pcbasic.main", line 168, in start_basic
    File "E:\pc-basic\packaging\windows\build\installer\out00-PYZ.pyz\pcbasic.run", line 46, in start
    File "E:\pc-basic\packaging\windows\build\installer\out00-PYZ.pyz\pcbasic.run", line 60, in run_once
    File "E:\pc-basic\packaging\windows\build\installer\out00-PYZ.pyz\pcbasic.statements", line 108, in parse_statement
    File "E:\pc-basic\packaging\windows\build\installer\out00-PYZ.pyz\pcbasic.statements", line 1979, in exec_input
    File "E:\pc-basic\packaging\windows\build\installer\out00-PYZ.pyz\pcbasic.devices", line 367, in read_var
    File "E:\pc-basic\packaging\windows\build\installer\out00-PYZ.pyz\pcbasic.devices", line 389, in _input_entry
    File "E:\pc-basic\packaging\windows\build\installer\out00-PYZ.pyz\pcbasic.devices", line 452, in read
    File "E:\pc-basic\packaging\windows\build\installer\out00-PYZ.pyz\pcbasic.ports", line 256, in read_raw
    File "E:\pc-basic\packaging\windows\build\installer\out00-PYZ.pyz\pcbasic.ports", line 231, in check_read
    TypeError: can't concat NoneType to bytearray

    Further, it crashes when I execute the loc() function (which works in the 15.03.5 release)

    OPEN "COM2:9600,N,8,1,RS,DS,CS,CD" FOR RANDOM AS 1
    A=LOC(1)
    

    with the following message:

    ERROR: Unhandled exception
    Traceback (most recent call last):
    File "E:\pc-basic\packaging\windows\build\installer\out00-PYZ.pyz\pcbasic.main", line 168, in start_basic
    File "E:\pc-basic\packaging\windows\build\installer\out00-PYZ.pyz\pcbasic.run", line 46, in start
    File "E:\pc-basic\packaging\windows\build\installer\out00-PYZ.pyz\pcbasic.run", line 60, in run_once
    File "E:\pc-basic\packaging\windows\build\installer\out00-PYZ.pyz\pcbasic.statements", line 100, in parse_statement
    File "E:\pc-basic\packaging\windows\build\installer\out00-PYZ.pyz\pcbasic.statements", line 1886, in exec_let
    File "E:\pc-basic\packaging\windows\build\installer\out00-PYZ.pyz\pcbasic.expressions", line 74, in parse_expression
    File "E:\pc-basic\packaging\windows\build\installer\out00-PYZ.pyz\pcbasic.expressions", line 245, in parse_expr_unit
    File "E:\pc-basic\packaging\windows\build\installer\out00-PYZ.pyz\pcbasic.expressions", line 571, in value_loc
    File "E:\pc-basic\packaging\windows\build\installer\out00-PYZ.pyz\pcbasic.ports", line 307, in loc
    File "E:\pc-basic\packaging\windows\build\installer\out00-PYZ.pyz\pcbasic.ports", line 231, in check_read
    TypeError: can't concat NoneType to bytearray

    I hope the error messages help.

    Patrik

     
    • Rob Hagemans

      Rob Hagemans - 2015-12-01

      Thanks Patrik, the error messages pointed me straight at the bug (the same one in both cases - a function missing a return value).

      Is it possible for you to set up the source version from git? I'm asking because it would enable you to get this fix quicker; it may end up being a couple of weeks before I do a new packaged release. In particular if there are any follow-up fixes needed this would speed up the process a lot, since packaging a release is fairly time-consuming.

      There may well be further regressions from 15.03.5 is between these releases the device code has gone through big changes. Apart from your feedback, the code accessing physical serial ports is largely untested - since I do not have one and had to make do with ports emulated through sockets.

      It's a bit of work installing the dependencies, but you only need to do that once. Happy to talk you through the process if you run into difficulties - there are instructions but I haven't got much feedback on how clear they are.

      Thanks again for helping test this!
      Rob

       
      • Anonymous

        Anonymous - 2015-12-03

        I followed the instructions in INSTALL.md (except installing pyparallel), but I got stuck with an error while running pcbasic. It seems that some encoding settings are not right, but I don't know where and how to change them. I hope you can help.

        Traceback (most recent call last):
        File "...\Continuum\Anaconda2\Lib\threading.py", line 810, in bootstrapinner
        self.run()
        File "...\Continuum\Anaconda2\Lib\threading.py", line 763, in run
        self.target(self.args, self.kwargs)
        File "...\pcbasic\video.py", line 73, in consumerthread
        while self.drainvideoqueue():
        File "...\pcbasic\video.py", line 105, in drainvideoqueue
        self.putglyph(signal.params)
        File "...\pcbasic\videoansi.py", line 192, in putglyph
        sys.stdout.write(char)
        File "...\Continuum\Anaconda2\Lib\encodings\cp850.py", line 12, in encode
        return codecs.charmapencode(input,errors,encodingmap)
        UnicodeEncodeError: 'charmap' codec can't encode character u'\u2190' in position 0: character maps to <undefined>

        Thanks, Patrik.

         
        • Rob Hagemans

          Rob Hagemans - 2015-12-03

          Hm, that's an annoying one. I'm not using Anaconda Python for PC-BASIC, seems their encoding settings are different so I haven't run into this issue before. We'll probably have to make a small kludge in the source to get this to work. I'll come up with something in a bit.

          Rob

           
          • Rob Hagemans

            Rob Hagemans - 2015-12-03

            It's a proper bug - no encoding is specified on the console output. In my install that worked but it's not correct. Will be fixed shortly.

            I realise one thing I didn't mention before: it looks like you're working off the master branch. That's fine if you get it working, but it's still quite rough around the edges. The code for the version you've been using so far, plus bugfixes, is in the release-15.08 branch. If you have git installed, you can switch to that branch with git checkout release-15.08.

            To get console output working correctly on WIndows you'll probably need the ansipipe launcher binary - either compile it with mingw32 or msvc++ from the source distribution or just take the small pcbasic.com (not the larger .exe!) from the 15.08.2 install and rename it ansipipe.exe in your source directory, then run with ansipipe python pcbasic. Without ansipipe you're likely to see a lot of gibberish being dumped into your console.

            Thanks
            Rob

             
            • Anonymous

              Anonymous - 2015-12-03

              Thanks a lot! With this help I got it to run.

               
              • Rob Hagemans

                Rob Hagemans - 2015-12-03

                Great! Now whenever there are bugfixes on that branch you can get them with with a git pull - let me know how things go with the serial access and hopefully we can hammer it all out so that it works.

                Cheers,
                Rob

                 
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.