From: CKL on
On 11 déc, 22:26, CKL <christian.klugesh...(a)gmail.com> wrote:
> On 11 déc, 17:13, CKL <christian.klugesh...(a)gmail.com> wrote:
>
>
>
> > On 11 déc, 16:22, CKL <christian.klugesh...(a)gmail.com> wrote:
>
> > > On 11 déc, 13:38, hae <r_haer...(a)gmx.de> wrote:
>
> > > > On 11 Dez., 10:49, CKL <christian.klugesh...(a)gmail.com> wrote:
>
> > > > > On 10 déc, 21:40, CKL <christian.klugesh...(a)gmail.com> wrote:
>
> > > > > > On 10 déc, 18:01, Uwe Klein <uwe_klein_habertw...(a)t-online.de> wrote:
>
> > > > > > > CKL wrote:
> > > > > > > > On 10 déc, 10:40, Uwe Klein <uwe_klein_habertw...(a)t-online.de> wrote:
>
> > > > > > > >>CKL wrote:
>
> > > > > > > >>>Uwe, I will perhaps change my opinion in some days, but for now,
> > > > > > > >>>please let me the "hope" to find another solution
>
> > > > > > > >>>Again, I really really appreciate your help
>
> > > > > > > >>If you want to stay in pure tcl you would have to
> > > > > > > >>emulate [exp_background] with [filevent].
> > > > > > > >>(i.e. assembling an input stream from successive reads
> > > > > > > >>    and interpret the content )
>
> > > > > > > >>uwe
>
> > > > > > > > I think that in all the cases, it will be a hard job.
> > > > > > > > * Pass to expect --> compile the source code, learn the language,
>
> > > > > > > expect is a tcl extension.
>
> > > > > > > > adapt it to my requirements, hope that it will work with freewrap,
>
> > > > > > > does freewrap work in the ActiveState installation? ( never used tcl2bin wrappers)
>
> > > > > > > > hope that it will do what I want, and hope that I will find the
> > > > > > > > solution
> > > > > > > > * Stay in tcl, rearrange completely my code, and expect a solution
>
> > > > > > > > It's damage that my code that I have written cannot be easily re-
> > > > > > > > arranged
> > > > > > > > I hopped, that relative to my code, there were only a little
> > > > > > > > adaptation to full fill my requirements..
>
> > > > > > > > Nevertheless I think it is not the case, and I'm little disappointed
> > > > > > > > to trash all my work :-(
>
> > > > > > > My "driver" for a Precisa (http://www.precisa.ch/) Scale
> > > > > > > is about 800lines/ 5kbyte tcl code.
>
> > > > > > > uwe
>
> > > > > > I use tcl in the mingw environment:http://wiki.tcl.tk/14828soIhave
> > > > > > to compile also expect.
> > > > > > Then, there will be  no problem to wrap it with freewrapper
>
> > > > > > An overview of my project:http://papsi.origo.ethz.ch/wiki/screenshots
>
> > > > > > IS-Papsi is written in tcl, and will only be used to configure the
> > > > > > dspic, and to move the stepper in case CNC controller is not used.
>
> > > > > > Christian
>
> > > > > Uwe,
>
> > > > > There is perhaps another solution to me to use freewrap and expect
> > > > > The only thing that I need is a compiled version of expect:
> > > > > Respectively following files.
> > > > > /Tcl/lib/expect/expect.tap
> > > > > /Tcl/lib/expect/expect.tcl
> > > > > /Tcl/lib/expect/injector.dll
> > > > > /Tcl/lib/expect/pkgIndex.tcl
> > > > > /Tcl/lib/expect/expect543.dll
>
> > > > > I tried to find these files, but I didn't find them
>
> > > > > Have you perhaps a way how to recover these files
>
> > > > > Thanks
>
> > > > > Christian
>
> > > > > to get expect:
> > > > > I find that
>
> > > > ActiveTcl has a recent version. Though you have to install it with
> > > > teacup.
>
> > > >http://community.activestate.com/faq/where-is-expect
>
> > > > Ruediger
>
> > > Hi Ruediger,
>
> > > I found effectively this information on Activetcl, but I didn't
> > > understand how to recover this package...
> > > This "Teacup", seems not to be easy to understand !
> > > Will have to read how it works :-(
>
> > > This is the risk when you meet an issue. In my case I was almost near
> > > to release my version, and now, I have to dive back..
> > > You start on the issue, but you don't know where you will land :-)
>
> > > CKL
>
> > I'm on the work for the moment, and there is  proxy to cross.
> > Didn't work with teacup install Expect --http-proxy....
>
> > Will try this evening- Masquer le texte des messages précédents -
>
> > - Afficher le texte des messages précédents -
>
> Just for information:
> Work with:
> teacup install Expect
>
> I now will try to understand what is behind this expect, and relative
> to your information, try to resolve my issue.
> When I will find the solution, will come back
>
> Christian

Hi All,

Finally, I think I have found the solution to my Problem.
Nevertheless I use the rules of Dave, where unexpected tasks should
never been blocked.
Decreasing also the TriggerTime, it was relatively easy to adapt my
program without a lot of changes.

Relative to your proposition to resolve my issue with Expect, I
apologise, but although I didn't pass a lot of time to understand
Expect, I didn't understand the concept of Expect, nor how it could
help me with my issue.

A lot of people speaks about Expect, and use it.
Nevertheless I read also some articles, explaining that since some tcl
versions, the concept of Expect is today completely integrated in tcl,
and are no more required for telnet, ftp, ... tasks

In all the case there is something that I didn't integrated with
Expect

Now for all your help
Thanks

And below My program

set chid [open com1: r+]
fconfigure $chid -mode "9600,n,8,1" -blocking 0 -buffering none -
translation binary
fileevent $chid readable [list serial_receiver $chid]

set mode Waiting
set TriggerTime 50
set TimeOutDelay 2000

set ForcedWriteBuff() ""
set todoForcedWriteBuffCount 1
set nexttodoForcedWriteBuffCount 1

set FreeRunningReadCnt 1
set FreeRunningReadCntThres 100

set MessageRead ""

proc serial_receiver { chan } {
global mode
global MessageRead
global SerialMsg_Event

set data [read $chan]
append MessageRead $data
puts $MessageRead
if {$mode == "ForcedWrite"} {
if { [string range $MessageRead end-2 end] == "AKW"} {
set SerialMsg_Event AKW
}
} elseif {$mode == "FreeRunningRead"} {
if { [string range $MessageRead end-2 end] == "AKR"} {
set SerialMsg_Event AKR
}
}
}

proc FreeRunningRead { } {
global chid
global mode
global MessageRead
global TimeOutDelay
global SerialMsg_Event

set mode "FreeRunningRead"

puts "Start FreeRunningRead"
puts -nonewline $chid "RTR"
puts -nonewline $chid \x0D
puts -nonewline $chid \x0A

set MessageRead ""
after $TimeOutDelay { set SerialMsg_Event TimeOut }
vwait SerialMsg_Event

switch $SerialMsg_Event {
"TimeOut" {
puts " FreeRunningRead TimeOut"
}
"AKR" {
puts " FreeRunningRead = $MessageRead"
}
}

puts " Stop FreeRunningRead"
set mode "Waiting"
}

proc ForcedWrite { cmd } {
global chid
global mode
global MessageRead
global TimeOutDelay
global SerialMsg_Event

set mode "ForcedWrite"

puts "Start ForcedWrite"

puts -nonewline $chid "$cmd "
puts -nonewline $chid \x0D
puts -nonewline $chid \x0A

set MessageRead ""
after $TimeOutDelay { set SerialMsg_Event TimeOut }
vwait SerialMsg_Event

switch $SerialMsg_Event {
"TimeOut" {
puts " ForcedWrite TimeOut for cmd = $cmd"
}
"AKW" {
puts " ForcedWrite = $MessageRead for cmd = $cmd"
}
}

puts " Stop ForcedWrite"
set mode "Waiting"

}

wm protocol . WM_DELETE_WINDOW { exit }
button .b1 -text Quit -command { exit }
button .b2 -text Write -command {
global ForcedWriteBuff
global todoForcedWriteBuffCount
global nexttodoForcedWriteBuffCount

# All Job has been Done, we can reset the counter
if { $nexttodoForcedWriteBuffCount == $todoForcedWriteBuffCount }
{
set todoForcedWriteBuffCount 1
set nexttodoForcedWriteBuffCount 1
}

set ForcedWriteBuff($todoForcedWriteBuffCount) "UP"
puts " -ForcedWriteBuff($todoForcedWriteBuffCount) =
$ForcedWriteBuff($todoForcedWriteBuffCount)"

incr todoForcedWriteBuffCount
}
pack .b1
pack .b2

# Loop
proc repeat {delay script} {
if 1 $script
after $delay repeat $delay $script

}

# Run at priority the unexpected event
proc exec_expected_unexpected_tasks {} {
global ForcedWriteBuff
global todoForcedWriteBuffCount
global nexttodoForcedWriteBuffCount
global FreeRunningReadCnt
global FreeRunningReadCntThres

while {$nexttodoForcedWriteBuffCount < $todoForcedWriteBuffCount}
{
ForcedWrite "$ForcedWriteBuff($nexttodoForcedWriteBuffCount)
$nexttodoForcedWriteBuffCount"
incr nexttodoForcedWriteBuffCount
}

incr FreeRunningReadCnt
if {$FreeRunningReadCnt == $FreeRunningReadCntThres } {
FreeRunningRead
set FreeRunningReadCnt 1
}
}

# Run each TriggerTime
repeat $TriggerTime exec_expected_unexpected_tasks
First  |  Prev  | 
Pages: 1 2 3 4 5
Prev: ANNOUNCE: Jeszra ZERO-ONE
Next: PureTkGUI v0.9.0 is out