April 23, 2024, 06:32:00 PM

News:

IonicWind Snippit Manager 2.xx Released!  Install it on a memory stick and take it with you!  With or without IWBasic!


Keyboard input

Started by Egil, January 29, 2011, 08:42:43 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Egil

The code below show the main loop of a simple console mode serial comms program. When communicating with a TNC (Terminal Node Controller - a modem for datatransmission), everything works as expected, since all commands and text are sent character by character as soon as I tap the keyboard.
In GUI mode I copy the text written in an RE-control to a string every time I hit ENTER. Then this string is sent to the TNC. But the TNC doesn't quite like these strings. It accepts all comands sent, but is always returning an extra line indicating that it doesnt interpret the last command or character. But the modem executes the commands correctly. I suspect the error indicator is returned because of the  zerocharacter trailing all strings.
Now I wonder if there is a way to do such charactrer by character transmissions with a GUI program? (I already have tried sending the string character by character in a for/next loop, but the result was the same)

'
'Ã,¨Ã,¨Ã,¨Ã,¨Ã,¨Ã,¨Ã,¨Ã,¨Ã,¨Ã,¨Ã,¨Ã,¨Ã,¨Ã,¨ Main loop Ã,¨Ã,¨Ã,¨Ã,¨Ã,¨Ã,¨Ã,¨Ã,¨Ã,¨Ã,¨Ã,¨Ã,¨Ã,¨Ã,¨Ã,¨Ã,¨Ã,¨Ã,¨Ã,¨Ã,¨Ã,¨Ã,¨Ã,¨Ã,¨Ã,¨Ã,¨Ã,¨Ã,¨Ã,¨Ã,¨Ã,¨Ã,¨Ã,¨Ã,¨Ã,¨Ã,¨Ã,¨Ã,¨Ã,¨Ã,¨Ã,¨Ã,¨Ã,¨Ã,¨Ã,¨Ã,¨Ã,¨Ã,¨Ã,¨
'
DO
' Rxd:
print GetRxD(COMPORT),

' Txd:
key$=""
key$ = INKEY$
IF key$ <> ""
SendComportString(COMPORT,key$,1)
if key$ = chr$(13) then print
print key$,
ENDIF
UNTIL key$ = CHR$(27)
'Ã,¨Ã,¨Ã,¨Ã,¨Ã,¨Ã,¨Ã,¨Ã,¨Ã,¨Ã,¨Ã,¨Ã,¨Ã,¨Ã,¨Ã,¨Ã,¨Ã,¨Ã,¨Ã,¨Ã,¨Ã,¨Ã,¨Ã,¨Ã,¨Ã,¨Ã,¨Ã,¨Ã,¨Ã,¨Ã,¨Ã,¨Ã,¨Ã,¨Ã,¨Ã,¨Ã,¨Ã,¨Ã,¨Ã,¨Ã,¨Ã,¨Ã,¨Ã,¨Ã,¨Ã,¨Ã,¨Ã,¨Ã,¨Ã,¨Ã,¨Ã,¨Ã,¨Ã,¨Ã,¨Ã,¨Ã,¨Ã,¨Ã,¨Ã,¨Ã,¨Ã,¨Ã,¨Ã,¨Ã,¨Ã,¨Ã,¨Ã,¨Ã,¨Ã,¨Ã,¨Ã,¨Ã,¨Ã,¨Ã,¨Ã,¨


Egil
Support Amateur Radio  -  Have a ham  for dinner!

LarryMc

just guessing here -

Quote(I already have tried sending the string character by character in a for/next loop, but the result was the same)
If you are sending it character by character but still as a string the trailing zero is still there.
Use a CHAR variable instead of a STRING variable for each character sent and see what happens.
And check in your loop to make sure you don't send a 0 value.

Or, in your loop check to make sure the CR isn't being sent chr$(13) or LF chr$(10).

Like I said, just guessing.

LarryMc
LarryMc
Larry McCaughn :)
Author of IWB+, Custom Button Designer library, Custom Chart Designer library, Snippet Manager, IWGrid control library, LM_Image control library

Egil

For CR must be sent, but there is sent an additional character, that I haven't been able to identify. But it is not a big deal. All that happen is that the TNC answers with the text "EH?", which means that the command is "not valid". But every command I send is executed. And when connected to another radio amateur, nothing is transmitted until I press enter.

But I must confess that I like the simplicity of the console mode loop, and really miss to be able to do it the same way in a GUI program.
Support Amateur Radio  -  Have a ham  for dinner!

LarryMc

There has to be a way; it's just that I'm not smart enough to know how to fix it for you.

LarryMc
LarryMc
Larry McCaughn :)
Author of IWB+, Custom Button Designer library, Custom Chart Designer library, Snippet Manager, IWGrid control library, LM_Image control library

sapero

Probably when you hit Enter, RE appends 13,10 as line break before you copy the text, so the additional character 10 is sent to your device. Try sending one byte less if you are sending a single line at a time.

Egil

I have already tried that Sapero, but then the TNC wouldn't recognize the commands. But it is not a great issue, since everything apparently works correctly, exept for the "EH?" response.
(the routines in question are used here: http://ebasic-aurora.com/forums/index.php?topic=4337.0)
If I send predefined strings instead of copying the edit control, everything works just fine. So guess I'll look up all commands in a predefined array and use them instead of the "raw" strings copied directly from the edit control.

Or maybe I'll manage to copy the console mode method by experimenting a little with @IDCHAR and @IDCODE. Haven't had time to experiment yet...

Egil
Support Amateur Radio  -  Have a ham  for dinner!

Egil

Sapero,
You were quite right about the LF character. There was a typo in the code where I tried to filter out the LF-character.
Sorry!
Support Amateur Radio  -  Have a ham  for dinner!

LarryMc

Quote from: Egil on January 30, 2011, 08:25:20 AM
Sapero,
You were quite right about the LF character.
Hmmmm. That sounds familiar...

Quote from: LarryMcOr, in your loop check to make sure the CR isn't being sent chr$(13) or LF chr$(10).

I couldn't resist. ;D ;D

LarryMc
LarryMc
Larry McCaughn :)
Author of IWB+, Custom Button Designer library, Custom Chart Designer library, Snippet Manager, IWGrid control library, LM_Image control library

Egil

It must be my new glasses....
Think I read 0 instead of 10 when I checked the string contents. Do you think I ought to go back to the shop to complain?

I have corrected the code and updated the example I posted in the GUI section. ( http://ebasic-aurora.com/forums/index.php?topic=4337.0 )

I really hope it's my glasses..... ::)

Egil
Support Amateur Radio  -  Have a ham  for dinner!