Hi Erich,
You are pretty right...
Wait the " ok" and then the "\n> " prompt is not a valid solution.
In the middle of a ":" definition, the response is a sole " ok" without a 
prompt so it is ambiguous in general.
I've also tried to wait for an error message r"\?\? -\d+ \d+ \n> $" to stop the 
loop while any other response was intended ok.
But I still have the timeout calibrating problem.
An unambiguous EOT char will state that mcu is ready.

Paolo


Inviato da Samsung Mobile

-------- Original message --------
Subject: [Amforth] Adding WANT_X and a forth constant in asm (was: HW flow
        control) 
From: Erich Waelde <ew.fo...@nassur.net> 
To: amforth-devel@lists.sourceforge.net 
CC:  

Hi Paolo,

Thank you for your response.

On 08/02/2014 01:39 PM, Paolo Garro wrote:
> Hi Erich 
> There is nothing wrong.
> Me too I'm reading the echo char while transmitting.
> The timeout problem is while receiving form the mcu. 
> After transmitting a line you stay earing for a response.
> How can I know when the response is complete?
When you received the prompt "\n> ".
> Wait a lot of seconds is not so logic.
> How can I know if the mcu is ready to receive another line?
When you received the "\n> " prompt, too, I think.

> An XON ending char would be fine...

I have the timeout question in my stuff as well, but it is
not easy. There are several (more than 1) controllers on
the same rs485 bus. I do not want them to just send anything
unless I asked them. So I removed any output from startup
including the prompt. When I address one controller I send
its address (with the highest bit set) and it shall "wake up"
and present it's prompt. I also added the controller address
to the prompt itself, a station with address $4f will answer
as
"\n~4F> "
and the programm controlling everything needs to wait for this
string to be received. This particular setup cannot work with
xon/xoff. The bus has only one pair of cables. Therefore I want
to see each and every character echoed, so I know the remote
station is still avalailable (connected and alive). But that
is just my setup and I'm not saying, you are wrong. I just
doubt that it will help you as much as you think.


So lets assume for the moment, you want XOFF/XON hw flow control.
Fine. So you select two output pins of the controller to drive
the signals. Still fine. Next question: where in amForth do you
assert the xon and xoff signals? I might be wrong, but the
prompt function looks like the correct place to me to assert XON.
You are at the same place, where the prompt is sent. So does
XON help you? 

Again, I might be wrong alltogether. And if you really want xon/xoff,
it can definitely be added to your system. And if it works, great!

You can add
.set WANT_XON_XOFF = 1
in your "template.asm" or equivalent file and use it in any other
assembly file like so

.if  WANT_XON_XOFF == 1
  .set XON_XOFF_PORT = PORTD    ; io location, not mem mapped
  .set XON_XOFF_PIN  = 7
.endif

or similar. If you want to have a FORTH constant at the same time
to know for example the pin number, then you create the equivalent
asm code in a file (words/xon_xoff.asm for example):

; asm(XON_XOFF_PIN) constant xon_xoff_pin
VE_XON_XOFF_PIN:
    .dw $FF0C
    .db "xon_xoff_pin"
    .dw VE_HEAD
    .set VE_HEAD = VE_XON_XOFF_PIN
XT_XON_XOFF_PIN:
    .dw PFA_DOVARIABLE
PFA_XON_XOFF_PIN:
    .dw XON_XOFF_PIN

this creates the "xon_xoff_pin" as a forth constant. Please note
that this code is adapted from my experiments with amForth-4.6, so
it might need to change for a current version. The file needs to
be included into your build via dict_appl.inc

.if  WANT_XON_XOFF == 1
  .include "words/xon_xoff.asm"
.endif

Rebuild amForth, test, repeat. Look into core/words/ for inspiration.

Hope this helps and good luck!

Cheers,
Erich


------------------------------------------------------------------------------
Want fast and easy access to all the code in your enterprise? Index and
search up to 200,000 lines of code with a free copy of Black Duck
Code Sight - the same software that powers the world's largest code
search on Ohloh, the Black Duck Open Hub! Try it now.
http://p.sf.net/sfu/bds
_______________________________________________
Amforth-devel mailing list for http://amforth.sf.net/
Amforth-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/amforth-devel
------------------------------------------------------------------------------
Want fast and easy access to all the code in your enterprise? Index and
search up to 200,000 lines of code with a free copy of Black Duck
Code Sight - the same software that powers the world's largest code
search on Ohloh, the Black Duck Open Hub! Try it now.
http://p.sf.net/sfu/bds
_______________________________________________
Amforth-devel mailing list for http://amforth.sf.net/
Amforth-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/amforth-devel

Reply via email to