Re: [PATCH 1/2] xyz-modem: Wait infinitely for initial y-modem packet

2022-08-27 Thread Pali Rohár
On Monday 13 September 2021 15:02:50 Wolfgang Denk wrote:
> Dear Pali Rohár,
> 
> In message <20210913122245.my6ik4yjy7rwlh65@pali> you wrote:
> >
> > Timeout is not too slow, but sometimes user is (when is interrupted by
> > other things during selecting file). And then it is not obvious why
> > sx/sb command is failing... compared to transfer via gkermit which do
> > not have this "problem".
> 
> I see.
> 
> > > > So... I do not know what is better if current behavior or this new which
> > > > changes UI interaction.
> > > 
> > > We can do both, and still solve your problem: make the timeout
> > > adjustable so you can set it to something you can conveniently work
> > > with.
> >
> > Good point! env with timeout (or easier would be retry count?) seems
> > like a ideal solution how to "define" behavior without changing default
> > one. And e.g. negative value can mean infinite to support all possible
> > combinations.
> 
> I would recommend to define a timeout (in seconds), this is easier
> to understand for the end user - without looking at the source code
> they cannot know how a retry count translates into a time interval.
> And yes, setting the timeout to 0 could mean it waits forever.

This behavior is now implemented in v2. Current default timeout
(measured 90s) stay same for compatibility reasons.


Re: [PATCH 1/2] xyz-modem: Wait infinitely for initial y-modem packet

2021-09-13 Thread Tom Rini
On Mon, Sep 13, 2021 at 01:08:06PM +0200, Pali Rohár wrote:
> On Monday 13 September 2021 12:42:42 Wolfgang Denk wrote:
> > Dear Pali Rohár,
> > 
> > In message <20210910204653.3066-1-p...@kernel.org> you wrote:
> > > Now when command loady can be aborted / cancelled by CTRL+C, change wait
> > > timeout for initial packet to infinite. This would allow user to not be
> > > hurry when locating file which want to send. Commands loadb and loads
> > > already waits infinitely too.
> > 
> > I'm not sure if this is a good idea.
> > 
> > If you use loady in any kind of scripts, this would now hard hang
> > the system, while until now it was possible to recover from the
> > error.
> 
> Yes, this is a good point. But on the other hand, 'loadb' and 'loads'
> commands already have this behavior. So question is if it is better to
> have same behavior in all 'load?' commands or each 'load?' would behave
> differently... Because for software which transmit files and supports
> more protocols (e.g. both x-modem and kermit) it may be a nightmare if
> receiver behaves differently...
> 
> > This is a change to the user interface that is not really necessary,
> > so I recommend NOT to change the behaviour here, especially as it
> > does not hurt.
> 
> Well... there is an issue if you do not start file transfer in the
> timeout which current 'loady' command expects.
> 
> If you do not have integrated y-modem support in your terminal you have
> to do:
> 
> 1) open terminal and write 'loady' into U-Boot console
> 2) disconnect terminal
> 3) start y-modem software
> 4) choose file to transmit
> 5) instruct y-modem software to start transfer

So, when does this happen?  It's been a long long time since I used
minicom, but I know in screen you can do a filter to trigger the
transfer, ie:
:exec !! /home/trini/bin/load-boot-xymodem.sh
is one of the things in my notes and little script is just to sx SPL and
then sx --ymodem U-Boot itself.  I know tmux is the preferred tool of
power users these days but I assume it can do similar.

-- 
Tom


signature.asc
Description: PGP signature


Re: [PATCH 1/2] xyz-modem: Wait infinitely for initial y-modem packet

2021-09-13 Thread Wolfgang Denk
Dear Pali Rohár,

In message <20210913122245.my6ik4yjy7rwlh65@pali> you wrote:
>
> Timeout is not too slow, but sometimes user is (when is interrupted by
> other things during selecting file). And then it is not obvious why
> sx/sb command is failing... compared to transfer via gkermit which do
> not have this "problem".

I see.

> > > So... I do not know what is better if current behavior or this new which
> > > changes UI interaction.
> > 
> > We can do both, and still solve your problem: make the timeout
> > adjustable so you can set it to something you can conveniently work
> > with.
>
> Good point! env with timeout (or easier would be retry count?) seems
> like a ideal solution how to "define" behavior without changing default
> one. And e.g. negative value can mean infinite to support all possible
> combinations.

I would recommend to define a timeout (in seconds), this is easier
to understand for the end user - without looking at the source code
they cannot know how a retry count translates into a time interval.
And yes, setting the timeout to 0 could mean it waits forever.

Best regards,

Wolfgang Denk

-- 
DENX Software Engineering GmbH,  Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: w...@denx.de
The optimum committee has no members.
   - Norman Augustine


Re: [PATCH 1/2] xyz-modem: Wait infinitely for initial y-modem packet

2021-09-13 Thread Pali Rohár
On Monday 13 September 2021 14:12:54 Wolfgang Denk wrote:
> Dear Pali Rohár,
> 
> In message <20210913110806.27hc36n6gmhw6uq4@pali> you wrote:
> >
> > > If you use loady in any kind of scripts, this would now hard hang
> > > the system, while until now it was possible to recover from the
> > > error.
> >
> > Yes, this is a good point. But on the other hand, 'loadb' and 'loads'
> > commands already have this behavior. So question is if it is better to
> > have same behavior in all 'load?' commands or each 'load?' would behave
> > differently... Because for software which transmit files and supports
> > more protocols (e.g. both x-modem and kermit) it may be a nightmare if
> > receiver behaves differently...
> 
> Yes, you are right, there is an unlucky difference in behaviour.
> But all these interfaces are pretty old, and I would not invest
> efforts to fix a aproblem nobody ever noticed before, at the risk
> of breaking existing stuff.
> 
> I wonder if there are any users of 'loads' left - the Motorola
> S-record format is close to 50 years old and cumbersome to use.

Wow, I did not know that it is such old.

> I can't even remeber when I used it the last time - must be 15+ years
> or such.
> 
> 'loadb" is a different thing, but there you usually have kermit on
> the other side, and usually run an interactive session (or an
> automated one using something like  tbot ) - in any case, you
> normally have to interact on both sides.

There is also gkermit tool which do not implement interactive session,
only file transfer itself. And it is present in more linux distributions
so is quite popular...

> I never had a problem wih the current behaviour there.
> 
> 
> > If you do not have integrated y-modem support in your terminal you have
> > to do:
> >
> > 1) open terminal and write 'loady' into U-Boot console
> > 2) disconnect terminal
> > 3) start y-modem software
> > 4) choose file to transmit
> > 5) instruct y-modem software to start transfer
> >
> > And if 'loady' timeouts between 2) - 5) then it returns back to the
> 
> If this happens, the timeout is inconveniently short of you are too
> slow.  I think what would be helpful is to make the timeout
> adjustable (env var).

Timeout is not too slow, but sometimes user is (when is interrupted by
other things during selecting file). And then it is not obvious why
sx/sb command is failing... compared to transfer via gkermit which do
not have this "problem".

> > So... I do not know what is better if current behavior or this new which
> > changes UI interaction.
> 
> We can do both, and still solve your problem: make the timeout
> adjustable so you can set it to something you can conveniently work
> with.

Good point! env with timeout (or easier would be retry count?) seems
like a ideal solution how to "define" behavior without changing default
one. And e.g. negative value can mean infinite to support all possible
combinations.

> Best regards,
> 
> Wolfgang Denk
> 
> -- 
> DENX Software Engineering GmbH,  Managing Director: Wolfgang Denk
> HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
> Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: w...@denx.de
> "I can call spirits from the vasty deep."
> "Why so can I, or so can any man; but will they come when you do call
> for them?"  - Shakespeare, 1 King Henry IV, Act III, Scene I.


Re: [PATCH 1/2] xyz-modem: Wait infinitely for initial y-modem packet

2021-09-13 Thread Wolfgang Denk
Dear Pali Rohár,

In message <20210913110806.27hc36n6gmhw6uq4@pali> you wrote:
>
> > If you use loady in any kind of scripts, this would now hard hang
> > the system, while until now it was possible to recover from the
> > error.
>
> Yes, this is a good point. But on the other hand, 'loadb' and 'loads'
> commands already have this behavior. So question is if it is better to
> have same behavior in all 'load?' commands or each 'load?' would behave
> differently... Because for software which transmit files and supports
> more protocols (e.g. both x-modem and kermit) it may be a nightmare if
> receiver behaves differently...

Yes, you are right, there is an unlucky difference in behaviour.
But all these interfaces are pretty old, and I would not invest
efforts to fix a aproblem nobody ever noticed before, at the risk
of breaking existing stuff.

I wonder if there are any users of 'loads' left - the Motorola
S-record format is close to 50 years old and cumbersome to use.  I
can't even remeber when I used it the last time - must be 15+ years
or such.

'loadb" is a different thing, but there you usually have kermit on
the other side, and usually run an interactive session (or an
automated one using something like  tbot ) - in any case, you
normally have to interact on both sides.

I never had a problem wih the current behaviour there.


> If you do not have integrated y-modem support in your terminal you have
> to do:
>
> 1) open terminal and write 'loady' into U-Boot console
> 2) disconnect terminal
> 3) start y-modem software
> 4) choose file to transmit
> 5) instruct y-modem software to start transfer
>
> And if 'loady' timeouts between 2) - 5) then it returns back to the

If this happens, the timeout is inconveniently short of you are too
slow.  I think what would be helpful is to make the timeout
adjustable (env var).

> So... I do not know what is better if current behavior or this new which
> changes UI interaction.

We can do both, and still solve your problem: make the timeout
adjustable so you can set it to something you can conveniently work
with.

Best regards,

Wolfgang Denk

-- 
DENX Software Engineering GmbH,  Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: w...@denx.de
"I can call spirits from the vasty deep."
"Why so can I, or so can any man; but will they come when you do call
for them?"  - Shakespeare, 1 King Henry IV, Act III, Scene I.


Re: [PATCH 1/2] xyz-modem: Wait infinitely for initial y-modem packet

2021-09-13 Thread Pali Rohár
On Monday 13 September 2021 12:42:42 Wolfgang Denk wrote:
> Dear Pali Rohár,
> 
> In message <20210910204653.3066-1-p...@kernel.org> you wrote:
> > Now when command loady can be aborted / cancelled by CTRL+C, change wait
> > timeout for initial packet to infinite. This would allow user to not be
> > hurry when locating file which want to send. Commands loadb and loads
> > already waits infinitely too.
> 
> I'm not sure if this is a good idea.
> 
> If you use loady in any kind of scripts, this would now hard hang
> the system, while until now it was possible to recover from the
> error.

Yes, this is a good point. But on the other hand, 'loadb' and 'loads'
commands already have this behavior. So question is if it is better to
have same behavior in all 'load?' commands or each 'load?' would behave
differently... Because for software which transmit files and supports
more protocols (e.g. both x-modem and kermit) it may be a nightmare if
receiver behaves differently...

> This is a change to the user interface that is not really necessary,
> so I recommend NOT to change the behaviour here, especially as it
> does not hurt.

Well... there is an issue if you do not start file transfer in the
timeout which current 'loady' command expects.

If you do not have integrated y-modem support in your terminal you have
to do:

1) open terminal and write 'loady' into U-Boot console
2) disconnect terminal
3) start y-modem software
4) choose file to transmit
5) instruct y-modem software to start transfer

And if 'loady' timeouts between 2) - 5) then it returns back to the
U-Boot console. So y-modem software in step 5) starts interaction with
U-Boot console instead of 'loady' and try to interpret U-Boot prompt as
y-modem sequence... which is detected as garbage and y-modem software
would either wait or try retransmit... which sends some garbage to
U-Boot console and something may be executed.

'loadb' commands does not have this issue as it waits either for CTRL+C
or for successful kermit transfer.


So... I do not know what is better if current behavior or this new which
changes UI interaction.

> Best regards,
> 
> Wolfgang Denk
> 
> -- 
> DENX Software Engineering GmbH,  Managing Director: Wolfgang Denk
> HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
> Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: w...@denx.de
> "I've finally learned what `upward compatible' means. It means we get
> to keep all our old mistakes." - Dennie van Tassel


Re: [PATCH 1/2] xyz-modem: Wait infinitely for initial y-modem packet

2021-09-13 Thread Wolfgang Denk
Dear Pali Rohár,

In message <20210910204653.3066-1-p...@kernel.org> you wrote:
> Now when command loady can be aborted / cancelled by CTRL+C, change wait
> timeout for initial packet to infinite. This would allow user to not be
> hurry when locating file which want to send. Commands loadb and loads
> already waits infinitely too.

I'm not sure if this is a good idea.

If you use loady in any kind of scripts, this would now hard hang
the system, while until now it was possible to recover from the
error.

This is a change to the user interface that is not really necessary,
so I recommend NOT to change the behaviour here, especially as it
does not hurt.

Best regards,

Wolfgang Denk

-- 
DENX Software Engineering GmbH,  Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: w...@denx.de
"I've finally learned what `upward compatible' means. It means we get
to keep all our old mistakes." - Dennie van Tassel


[PATCH 1/2] xyz-modem: Wait infinitely for initial y-modem packet

2021-09-10 Thread Pali Rohár
Now when command loady can be aborted / cancelled by CTRL+C, change wait
timeout for initial packet to infinite. This would allow user to not be
hurry when locating file which want to send. Commands loadb and loads
already waits infinitely too.

Signed-off-by: Pali Rohár 
---
 common/xyzModem.c | 8 +++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/common/xyzModem.c b/common/xyzModem.c
index ece25acb183b..d6be489a174b 100644
--- a/common/xyzModem.c
+++ b/common/xyzModem.c
@@ -449,8 +449,14 @@ xyzModem_stream_open (connection_info_t * info, int *err)
   return 0;
 }
 
-  while (retries-- > 0)
+  while (1)
 {
+  if (--retries <= 0)
+{
+  retries = xyzModem_MAX_RETRIES;
+  crc_retries = xyzModem_MAX_RETRIES_WITH_CRC;
+  xyz.crc_mode = true;
+}
   stat = xyzModem_get_hdr ();
   if (stat == 0)
{
-- 
2.20.1