Thomas,
....but in our current version
May I conclude that in the next VIP-version, the closing problem does not exist anymore?
Still it doesn't have any thing to do with the unknown exception, the problem is that it happens on a timer event
You are absolutely right, but it was the closing problem that makes things difficult in the first place.
Anyway, I started two months ago with using the timer, after reading your tutorials on delaycall and exceptions.
I was fully aware of the problems I could expect with tickaction/delaycall in the timer event.
For the simple reason that there are a lot of uncertainties.
The interaction between two bluetooth devices is a mystery
There are RS232 timing events in windows,
There is the general eventhandling in windows which has influence on timing
The solutions/algortihms I use in my program are using time.
There are events in the c-code on the robot
There is the length of the messages laptop and robot are sending to each other.
There are sensorproperties on the robot.
Well, I am experimenting with the timer, gathering results to see if it is workable. If not, I have to look for another approach.
Here is the code I use for starting up and using the timer.
Code: Select all
predicates
onTimeronButton_ctl : button::clickResponder.
clauses
onTimeronButton_ctl(_Source) = button::defaultAction :-
% projectptr:to_commands(edit_ctl,message_ctl,toterm(readbytes_ctl:getText()),toterm(wait_ctl:getText())),
projectptr:to_commands(edit_ctl,message_ctl,toterm("10000"),toterm(wait_ctl:getText())),
not (timer1:isRunning()), % zet timer aan
edit_ctl:setText("adcl\nadc\nadcr"), % geef opdracht(en)
timer1:setTickDuration(700), % tijdsduur
timer1:start, % beginnen
!.
onTimeronButton_ctl(_Source) = button::defaultAction.
predicates
onTimer : window::timerListener.
% lees sensorwaarden in
% haal actie op
%
clauses
onTimer(_Source, _Timer) :-
if driving = false()
then
edit_ctl:setText("adcl\nadc\nadcr") ,
projectptr:to_commands(edit_ctl,message_ctl,toterm(readbytes_ctl:getText()),toterm(wait_ctl:getText())),
Command = projectptr:action(),
_ = vpi::processEvents(),
edit_ctl:setText(Command), % geef opdracht(en)
driving := true()
else
projectptr:to_commands(edit_ctl,message_ctl,toterm(readbytes_ctl:getText()),toterm(wait_ctl:getText())),
driving := false()
end if,
% projectptr:to_commands(edit_ctl,message_ctl,toterm(readbytes_ctl:getText()),toterm(wait_ctl:getText())),
% edit_ctl:setText("adcl\nadc\nadcr"). % geef opdracht(en)
!.
onTimer(_Source, _Timer).
By changing the tickduration to 400 milliseconds I could force the program to give an unknown exception.
The robot is reading three sensors and sends information back.
We are lucky and can just read some output.
On the screendump we see an empty tail. (left under).
I also can see (OE) in the header that this happens during the last command (adcr).
Apparently the RS232 buffer is empty: nothing to read. 400 millisecond is not enough.
Here is the full text:
========================================
Dump: 2016-08-26 12:51:56
----------------------------------------
Exception: unknown (exception)
An unknown exception has been trapped and continued
Predicate name = timerProc_tick
Arguments = Exception in tickAction/delayCall
continued 2016-08-26 12:39:45
ThreadId: 7028
Class name: window
Predicate name: timerProc_tick
----------------------------------------
Exception: indexOutOfRange (binary_exception)
Index out of binary limits
Predicate name = checkOffsetForSetGetValue
SourceCursor = pfc\binary\binary.pro(606,13)
Index = 0
binary size = 4
element size = 1
raised 2016-08-26 12:39:45
ThreadId: 7028
Class name: binary
Predicate name: checkOffsetForSetGetValue
c:\program files (x86)\visual prolog 7.5\pfc\exception\exception.pro(198)
C:\Users\Ben\Documents\RS232_Messages\Exe\vipKernel.dll (0x140083A5)
c:\program files (x86)\visual prolog 7.5\pfc\exception\exception.pro(198)
c:\program files (x86)\visual prolog 7.5\pfc\exception\exception.pro(182)
c:\program files (x86)\visual prolog 7.5\pfc\binary\binary_exception.pro(18)
c:\program files (x86)\visual prolog 7.5\pfc\binary\binary.pro(607)
c:\program files (x86)\visual prolog 7.5\pfc\binary\binary.pro(237)
boards\boardsupport.pro(394)
boards\boardsupport.pro(332)
boards\boardsupport.pro(253)
boards\boardsupport.pro(221)
boards\boardsupport.pro(92)
testing\userinterfacers232.pro(509)
c:\program files (x86)\visual prolog 7.5\pfc\gui\window.pro(1062)
c:\program files (x86)\visual prolog 7.5\pfc\gui\window.pro(1000)
C:\WINDOWS\System32\USER32.dll (0x7795D273)
C:\WINDOWS\System32\USER32.dll (0x7793EF95)
C:\WINDOWS\System32\USER32.dll (0x7793E283)
C:\WINDOWS\System32\USER32.dll (0x7794C521)
C:\Users\Ben\Documents\RS232_Messages\Exe\vipVpi.dll (0x1531A4EF)
c:\program files (x86)\visual prolog 7.5\pfc\vpi\vpi.pro(21)
c:\program files (x86)\visual prolog 7.5\pfc\windowsapi\exe_api\exe_api.pro(63)
c:\program files (x86)\visual prolog 7.5\pfc\application\exe\mainexe.pro(21)
main.pro(26)
C:\Users\Ben\Documents\RS232_Messages\Exe\vipKernel.dll (0x1400884B)
C:\Users\Ben\Documents\RS232_Messages\Exe\vipKernel.dll (0x14008B0B)
C:\Users\Ben\Documents\RS232_Messages\Exe\RS232_Messages.exe (0x00548F67)
C:\WINDOWS\SYSTEM32\ntdll.dll (0x77B50609)
C:\WINDOWS\SYSTEM32\ntdll.dll (0x77B505D4)
----------------------------------------
OS information:
Windows 8 64-bit (Build 9200)
Number Of Processors: 4 PageSize: 4096 Processor: 8664 level: 6 revision: 17665
ProcessorNameString: Intel(R) Core(TM) i5-4200U CPU @ 1.60GHz
VendorIdentifier: GenuineIntel
Identifier: Intel64 Family 6 Model 69 Stepping 1
~MHz: 2295
The code where the predicate gets an empty binary is here.
Code: Select all
predicates
tailCheck:(binary) -> boolean.
clauses
tailCheck(Tail) = true() :-
Length = binary::getSize(Tail),
etx = binary::getIndexed_unsigned8(Tail,uncheckedConvert(core::positive,Length-1)), % Index starts at 0
message:write("EndOfText = Ok\n"),
!.
tailCheck(Tail) = false() :-
Length = binary::getSize(Tail),
message:write("EndOfText must be ",etx," instead of ",binary::getIndexed_unsigned8(Tail,uncheckedConvert(core::positive,Length)),"\n"),
!.
Thanks for all your suggestions
Kind regards
Ben