Danitegue / PCBRW_OLD

A repository with all the needed things to run and control BREWER instruments software, under a Pyhton enviroment.
0 stars 0 forks source link

Baud rate change issues #4

Closed lildevilx closed 6 years ago

lildevilx commented 6 years ago

One issue that i keep running into now is that on the new electronics the brewers starts at 9600 baud and the program runs off that baud. However on the older electronics, the boards starts communication at 1200 baud and upon the restart via the program, the first thing it does is to change it to 9600 baud.

At this point the PCBRW crashes and spits out an error 'device I/O Error in 9280' Checking the log, it shows '[13:14:24.0796] INFO: ports.py, COMDevice, Opening a file on COM port, as file number 7 [13:14:30.0154] INFO: ports.py, COMDevice, Opening a file on COM port, as file number 7 [13:14:30.0335] INFO: ports.py, COMDevice, Opening a file on COM port, as file number 7 [13:14:54.0503] WARNING: I/O error on stream access: ClearCommError failed (WindowsError(6, 'The handle is invalid.'))'

it looks like ports.py isn't able to deal with the baud rate change in the middle of the program since if i just restart (typing "run") it will start back up and go into main. (since the baud rate has already been change, the program doesn't need to try to do an RE anymore). This causes 2 issues

  1. Since the brewer will do a force restart which will cause it to hang until someone goes and does a run command.
  2. the brewer doesn't actually do a reset at this point which can cause some problems. IE it won't make sure the filter wheels are where it thinks it is.

I'm also trying this on a double using new electronics, and it doesn't cause the same issue where RE would just hangs.

robhagemans commented 6 years ago

Given that it's a crash, this is a bug in PC-BASIC. However, it may be difficult to address as it looks like it may happen only in the specific circumstance of Windows + physical serial port, which I would not be able to reproduce.

From what you describe it looks like a baud rate change leads to a new stream being opened on the serial port, but PC-BASIC continues to use the old stream which is no longer valid. I'll have a look if I can see what causes that.

Rob

On Thu, 12 Jul 2018, 18:34 lildevilx, notifications@github.com wrote:

One issue that i keep running into now is that on the new electronics the brewers starts at 9600 baud and the program runs off that baud. However on the older electronics, the boards starts communication at 1200 baud and upon the restart via the program, the first thing it does is to change it to 9600 baud.

At this point the PCBRW crashes and spits out an error 'device I/O Error in 9280' Checking the log, it shows '[13:14:24.0796] INFO: ports.py, COMDevice, Opening a file on COM port, as file number 7 [13:14:30.0154] INFO: ports.py, COMDevice, Opening a file on COM port, as file number 7 [13:14:30.0335] INFO: ports.py, COMDevice, Opening a file on COM port, as file number 7 [13:14:54.0503] WARNING: I/O error on stream access: ClearCommError failed (WindowsError(6, 'The handle is invalid.'))'

it looks like ports.py isn't able to deal with the baud rate change in the middle of the program since if i just restart (typing "run") it will start back up and go into main. (since the baud rate has already been change, the program doesn't need to try to do an RE anymore). This causes 2 issues

  1. Since the brewer will do a force restart which will cause it to hang until someone goes and does a run command.
  2. the brewer doesn't actually do a reset at this point which can cause some problems. IE it won't make sure the filter wheels are where it thinks it is.

I'm also trying this on a double using new electronics, and it doesn't cause the same issue where RE would just hangs.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/Danitegue/PCBRW/issues/4, or mute the thread https://github.com/notifications/unsubscribe-auth/AHXYkvp2iWfxAbNrpER4AbD7iXCI97iHks5uF4iKgaJpZM4VNbVC .

lildevilx commented 6 years ago

Thanks Rob,

In the mean time I'll see if there are any other way around it, which is looking more like a no...

Let me know if you have any ideas you would like to test. I'm happy to give it a try, Thanks!

robhagemans commented 6 years ago

Ah, I note it's not an actual crash, just a BASIC error. It still looks like there might be some problem with streams though.

Is RE the Brewer command that is being executed when the error happens? I need to try to find the line of BASIC code that triggers it (i.e. the code in line 9280 and around it, at the time of the crash).

@lildevilx , could you perhaps, when the error happens, do a SAVE "errprog.txt",A (or some other new filename) and attach the output file ERRPROG.TXT here?

lildevilx commented 6 years ago

As you said, it doesn't fully seem like fully crashing as I can still run commands there.

it is the RE command that triggers the error occurring. The RE is suppose to be just an reset command sent to the brewers. how ever on the older units they start out on a lower baud, and RE automatically changes it back up to 9600. After that it does a bunch of other check on the system (which will be by-passed if i just ran the program again from there) The RE command is automatically ran once a day to flush out any memory leaks and runs the system checks.

in terms of the errprog.txt, i'm not very familiar on how to find the output of the file. Should this be saved somewhere on the computer? or do i have to open and view it from PC basic?

Thanks

lildevilx commented 6 years ago

@robhagemans Attach is the ERRORPRO.TXT outputted from SAVE "errorpro.txt" Let me know what else you might need. Thanks!

robhagemans commented 6 years ago

I've made a small fix (commit 618b6bf) to the PC-BASIC master branch, I'm hoping this will fix the issue once this is included in @Danitegue 's PCBRW fork

lildevilx commented 6 years ago

Hi Rob,

I went and download the fix from the master branch, and it seem to have fix the issue! After installing the new commit (618b6bf) from the master branch I notice it wasn't running right away. upon checking the logs for PCBRW, it started complaining about not having sdl2 installed which it never had an issue with the previous version. Looking at what you've changing in the ports.py file, it doesn't look like it would suddenly require sdl2... i tried reinstalling it with pip install pysdl2 and it doesn't seem to of fix the issue. instead i had to run conda install -c conda-forge sdl2 via anaconda instead.

either way, thanks for the fix! I'll leave this open to remind Danitegue to commit the new fix into his fork.

Thanks!

Danitegue commented 6 years ago

Hi, sorry for the late answer,

I have just applied the RH fix (commit 618b6bf) to the PCBRW. Thanks Rob, sorry for not being able to check it on time.

lildevilx:

PCBASIC can use some diferent consoles, ansi, sdl2, pygame.

As indicated here: https://github.com/robhagemans/pcbasic/blob/master/DEVELOPMENT.md for using sdl2 is needed to install the sdl2 package, and move some dlls to specific pcbasic folders.

In the case of the PCBRW branch, I have already included them into: \PCBRW\pcbasic\pcbasic\lib\win32_x64\SDL2.dll \PCBRW\pcbasic\pcbasic\lib\win32_x86\SDL2.dll

I know this is not the best solution, but is just for reducing the installation instructions.

These dlls are of course platform dependent, if you are running from linux, you can switch to pygame, changing in the launchers the argument --interface=sdl2 by --interface=pygame

lildevilx commented 6 years ago

Sounds good, Thanks guys!