<html><head></head><body><div style="color:#000; background-color:#fff; font-family:HelveticaNeue-Light, Helvetica Neue Light, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif;font-size:16px"><div id="yui_3_16_0_ym19_1_1462410530170_5570"><span></span></div><div></div><div id="yui_3_16_0_ym19_1_1462410530170_5547" dir="ltr">If the Free Vision code seems a bit complicated and complex to you, you may want to study the classic CRT unit (from the Turbo Pascal era). Basically it "draws" chars to the console screen, using method like ClrScr, GotoXY, WhereX, WhereY, etc. It's also able to read keystrokes, using method like ReadKey, Keypressed, etc. I think it's good enough for console app with simple interactions. However, I'm not sure whether it works with SSH and unicode.</div><div class="signature" id="yui_3_16_0_ym19_1_1462410530170_5520"><div id="yui_3_16_0_ym19_1_1462410530170_5519"><br></div>–Mr Bee<div id="yui_3_16_0_ym19_1_1462410530170_5521"><br></div></div> <div class="qtdSeparateBR" id="yui_3_16_0_ym19_1_1462410530170_5545"><br><br></div><div class="yahoo_quoted" id="yui_3_16_0_ym19_1_1462410530170_5544" style="display: block;"> <div style="font-family: HelveticaNeue-Light, Helvetica Neue Light, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif; font-size: 16px;" id="yui_3_16_0_ym19_1_1462410530170_5543"> <div style="font-family: HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif; font-size: 16px;" id="yui_3_16_0_ym19_1_1462410530170_5542"> <div dir="ltr" id="yui_3_16_0_ym19_1_1462410530170_5541"><font size="2" face="Arial" id="yui_3_16_0_ym19_1_1462410530170_5540"> Pada Jumat, 29 April 2016 1:28, Bo Berglund <bo.berglund@gmail.com> menulis:<br></font></div>  <br><br> <div class="y_msg_container" id="yui_3_16_0_ym19_1_1462410530170_5546">On Thu, 28 Apr 2016 15:23:01 +0200, Bo Berglund<br><<a ymailto="mailto:bo.berglund@gmail.com" href="mailto:bo.berglund@gmail.com">bo.berglund@gmail.com</a>> wrote:<br><br>I went ahead and created a new Console Application in Lazarus where I<br>use the same object for controlling the GPIO pins as I did in the GUI<br>program.<br><br>The Console program just initializes the control object then enters<br>into a repeat loop reading a key from the user and then interpreting<br>the key in a case construct for valid commands.<br>It exits if the q key is pressed.<br><br>When I run this in Lazarus all operates according to plan but as soon<br>as I try to run it outside of the GUI, for example in a terminal in<br>Raspbian or in a PuTTY terminal connected by SSH to the RPi literally<br>nothing works of the stuff that should happen in the repeat loop!<br><br>What I get is the greeting message and then when I press the keys that<br>should produce the action nothing at all happens including pressing q,<br>which is the exit code out of the loop and should terminate the<br>program.<br><br>For some reason it was possible to close it using Ctrl-C, though.<br><br>In Lazarus I use the debug window "Terminal Output" and here<br>everything planned works fine!<br><br>What a mystery! This is the first time I have encountered such a<br>difference!<br><br>After some further debugging I found that the keypresses are not even<br>handled in the repeat loop. It uses this type of construct:<br><br>  //Display main screen<br>  Writeln('Controls are:');<br>  Writeln('p = Toggle 12V SS Power ON/OFF');<br>  Writeln('w = Toggle WiFi Power feed ON/OFF');<br>  Writeln('l = Toggle Alarm Lamp ON/OFF');<br>  Writeln('s = Start SS by sending a 1s pulse');<br>  Writeln('q = Quit the program and reset the control lines');<br>  Writeln('Press any key!');<br><br>  //Check input and act on commands<br>  repeat<br>    Read(cKey);<br>    case cKey of<br>      'p': //SS Power toggle command<br>...<br>  until cKey = 'q';<br>end;<br><br>I added debug printing to the case sections to see what was sent in<br>and the answer was NOTHING!<br>It seems like Read() does not return anything for a simple key press<br>unlike what happens in the Lazarus debug window. So the program<br>probably just hangs on the Read(cKey) command, but in Lazarus it does<br>not so it is impossible to debug...<br><br>Then I tested to use the Enter key and surprise! Now the relays<br>operate...<br><br>But this should happen exactly when the key is pressed not when Enter<br>is also pressed later. I use Read() instead of Readln() just in order<br>to get one single key to process...<br><br>What could be done to fix this?<br><br>><br>>-- <br>>Bo Berglund<br>>Developer in Sweden<br><br><br>-- <br>Bo Berglund<br>Developer in Sweden<br><br><br>--<br>_______________________________________________<br>Lazarus mailing list<br><a ymailto="mailto:Lazarus@lists.lazarus.freepascal.org" href="mailto:Lazarus@lists.lazarus.freepascal.org">Lazarus@lists.lazarus.freepascal.org</a><br><a href="http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus" target="_blank">http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus</a><br><br><br></div>  </div> </div>  </div></div></body></html>