-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
First line wraps one character early #18
Comments
It seems to be related to an anomaly in the Pico SDK. Presumably for historical reasons, the routine
and
The Pico SDK provides its own version of
The I have tried replacing all the calls of the form:
by
That solves that particular issue, but now I am missing the ">" prompt after the I suspect there must also be an issue with the interaction of |
It may well be because my experience with BASIC made me assume that using |
Google suggests that |
All of those assumptions are reasonable in most cases, where all the output goes through a single library. They are almost certainly mandated by the Posix standard. However, the Pico is anomalous, with If I can create a simple example which illustrates the problem, I will raise an issue on the pico-sdk GitHub. Edit: Raised an issue for the |
The person who discovered the issue and reported it to me suggests the following fix: replace every If that works for you too, and you think it's a reasonable solution, I'm happy to go with it. |
Replacing With regards to the missing ">" prompt after the MODE command, it looks as though it is being output, but in column 999!
Edit: Resolved this with an additional |
Committed required changes. |
This is part of the mechanism for determining the terminal width. BBC BASIC sends the terminal a 'move the cursor to column 999' command, to which the terminal responds by moving it to the right-most column. BASIC then interrogates the cursor position and by that means discovers the width in characters. The cursor is moved back to the left-most column before the '>' is output. |
The OP has made this comment on the committed changes (he isn't a member of GitHub): "The solution of using printf is a mistake. The fact that the code needed an fflush to get the prompt back shows that it is unreliable - using fprintf does not require an fflush. You may have solved the problem with the mode 3 prompt but how many other untested display anomalies will require a random fflush to get the data in the correct order". Perhaps you could comment. I don't know enough about how the Pico-SDK implementation of |
The problem is that the cursor was not moved back before the '>' is output. If you look at the dump I posted, the '>' is output before the "[1;1H". Another example of output not being in the order of the subroutine calls. |
I am reluctant to use
|
Fair enough. I'm aware that it would require a lot of changes to bbccos.c too, which would impact on the other Console Mode editions (unless we were to split out the Pico version of that module but that would be a shame). And there's something rather unsettling about replacing Perhaps before putting this to bed we should wait for the reaction to your report of the issue because I would hope that this would be treated as quite a serious bug. If they fix it upstream in a timely fashion it should remove the residual concerns that the OP (Colin Granville) has. |
On further investigation I am more confused about The problem seems to be caused when the compiler optimises PicoBB already has a custom version of "bbccos.c" in order to provide the device specific star commands. That is the file which contains I have resolved the issue by defining the following macro in "bbpico.c" and "bbccos.c":
|
That seems less an 'optimisation' and more a 'breaking change'!
Are you sure? There are already
and
Perhaps you can check and if necessary I'll incorporate any changes required so my build has the same star commands as yours. |
Hi - I'm the person who informed Russell of this bug. Replacing printf with fprintf (stderr. was fairly easy with search and replace. There's 1 case with no space between the name and (. Then you just need to take care of the 4 sprintf cases. Can I suggest replacing printf with xprintf an the fwrites with xputchar Then create macros
and
Then you can change what functions are called easily. |
That may explain the different problems I have. I came across Russells uf2 when someone asked me to get it working with Hearsay on riscos. It turned out that at that time the version on Russells website would only connect to riscos usb intermittently. Memotech-Bills version was ok. I compiled an older version from Russells sources - that was ok and also didn't have a problem I have with both versions now and that is a 1 line width display caused by the response to the 999 tab being too slow despite it happening within 1 cs of receiving the tab. instruction. |
If you are using my Makefile to build, then you are using my version of bbccos.c. The attached file gives the differences. |
|
To make sure I pick up any changes I've made locally but not yet committed to GitHub, I copy my source files (bb*.c) over the top of yours as part of the build process (when I remember to, anyway, it's not currently automated). So if your custom version of
That shows the importance of me doing what I do - you've not incorporated in your version the modification which fixes the problem of opening a file with a comma in its name (which is the principal reason for the latest update to the Console Mode editions). Since there are rather a lot of additions I'm not sure it would be sensible to bloat the 'common' |
Did you notice that It seems to me that by far the best solution is for the upstream bug to be fixed, although of course I don't know how long that may take. But making extensive modifications, which impact on all the Console Mode editions, as a temporary workaround for a Pico-SDK bug isn't very attractive. |
I will have a look at this, however I am probably otherwise occupied for the next few days. |
Seems reasonable. It's not the end of the world that the bug isn't fixed for me. What is important for me is an explanation of the problem so I know it isn't mine :-) I just don't like seeing symptoms fixing as opposed to a real fix. It seems to me - not having any experience programming the pico that printf on a pico is not a complete printf more a means of abstracting output to different devices. Are putchar and printf in different libraries? If they don't work together - well that's fairly fundamental. the designers can't be that stupid it has to be deliberate. Have you tried making stdout non buffered |
I understand, but I trust that you will at least update your At the moment I have the choice of making two builds: one with the comma fix but not the Pico-specific star commands, or one with the star commands but not the comma fix! It also means that a user cannot trust the version number in my Pico UF2 to accurately reflect what features it contains. I know that sharing source files between projects is fraught, but it's the sort of thing that GitHub should make possible, so long as we're careful with where code specific to just one project (the Pico build in this case) goes. |
I have now refactored my code. The differences between my version of bbccos.c and yours are now:
Full version attached. If you are able to accept this version, then I will remove my copy.
Which folder do you copy your sources to? My makefile takes your sources from the folder PicoBB/BBCSDL/src, whereas my copy of bbccos.c is in folder PicoBB/src. |
The only thing I'd say is that by redefining To that extent what you've done is a bit of a cheat, because there is still a significant chunk of I do of course appreciate that this has made the 'refactoring' much more straightforward, so I can certainly see the attraction from your point of view. It's just that I have a residual concern that you might fail to spot (for example) bug fixes to the But I don't want to rock the boat too much so I'll merge your
Since it's (currently) a manual process I can't remember, but most likely (because I'm not familiar with the directory structure of the Pico build) I use Should the BBC_SRC variable still work in your build? That ought to be an easier and safer way of forcing it to use my latest local copies of the 'core' source files, but I stopped using it because it seemed not always to work. |
Not really: My version of
Yes, it shoud work. |
I bet, with what we know now, I concluded it was broken because it failed to replace |
Running this program:
results in the first line wrapping one character early on the Pico, but not when run locally in a native console; I don't understand why there should be a difference. Here is a screenshot from the Pico (PuTTY in Windows, the same thing happens with picoterm in Linux):
and here running locally (Windows):
The text was updated successfully, but these errors were encountered: