wish for Send String

If you have specific questions or problems with any of my Freeware applications, post them here.

wish for Send String

Postby kondou » Tue May 13, 2014 8:53 am

Hi,

I have a serial device which reads serial data and creates keyboard output(USB) data based on the input. The
keyboard output data can be sent to another PC and this device is treated as USB keyboard. In this device, all
ASCII characters are sent as is to USB, but other special cases like ESC, Control, Function keys, etc. can be created
by sending Hex data (not ASCII) to this device. This device will be useful for me, if CoolTerm behaves like what
I want. Because I can use my favorite key assignment, while the USB connected PC side does not need key re-assignment.

Here is what I want CoolTerm to do to realize what I want:

- default mode (ASCII or HEX) for Send String can be determined in Preferences.
- The content of Send String window is automatically cleared when Send button is clicked.
- Send button for Hex mode also can be clicked by Return key.

Is it possible to realize this function? Or, can I do what I want by using current CoolTerm functionality?
The version of CoolTerm is 1.4.3(Build 203), and the OS is OS X 10.9.2.
--
Katsuhiro Kondou
kondou
 
Posts: 5
Joined: Mon May 12, 2014 9:05 pm

Re: wish for Send String

Postby roger » Tue May 13, 2014 5:14 pm

Can you elaborate on what kind of data you typically send to your device? How do you normally talk to it?
User avatar
roger
Site Admin
 
Posts: 215
Joined: Fri Apr 24, 2009 12:41 am

Re: wish for Send String

Postby kondou » Wed May 14, 2014 2:16 am

All data will be hex. As for ASCII characters, they are from 0x20 to 0x7F. Other keys are translated from other
values by the device, and the values are;

0xA1 and 0x0D for Enter(Return)
0xA2 and 0x1B for ESC
0xA3 for TAB
0xA4 for right arrow
0xA5 for left arrow
0xA6 for down arrow
0xA7 for up arrow
from 0xF1 to 0xFC for from F1 to F12
0xE4 for Home
0xE7 for End
0x08 for back space

Also there are keys for Control, Shift and ALT for modifier. These keys are;
0x80 for Control
0x81 for Shift
0x82 for ALT
0x83 for Control and ALT

I'd want to send above values to the device. I'm going to use KeyRemap4MacBook to translate my key typing
into above values to enter Send String window. E.g. "41+Return" for "A", "806D+Return" for "Control-M", "F1+Return"
for F1 key, etc.
kondou
 
Posts: 5
Joined: Mon May 12, 2014 9:05 pm

Re: wish for Send String

Postby roger » Wed May 14, 2014 11:54 am

I see.

There are already a few shortcuts in CoolTerm you can you to speed things up when using the 'Send String' window:
- You can toggle from plain to hex in the 'Send String' window using ALT+ENTER
- You can send the data using SHIFT+ENTER
- After sending the data you can press CTRL+A to select all the text. Once you start typing new date, the selected data will be erased.

You can also have multiple 'Send String' windows open if you want have multiple strings that you frequently use available.

Do you have control over the ASCII character mapping of your device? If so, you could change the mapping such that it accepts the characters that CoolTerm sends for these special keys. CoolTerm doesn't do a mapping of its own but it sends the ASCII codes that it receives from the operating system for these keys. Thus, this is platform dependent for some of the keys. Here is a list of ASCII codes for special keys and key combinations based on the platform:

Code: Select all
         Windows   Mac
       
HOME     01        01
ENTER    03        03
END      04        04
INSERT             05   
BS       08        08
TAB      09        09
PAGE UP  0B        0B
PAGE DN  0C        0C
RETURN   depends on the Enter key emulation in CoolTerm
LEFT     1C        1C
RIGHT    1D        1D
UP       1E        1E
DOWN     1F        1F
ESC      27        27
F1       C8        EF 9C 84
F2       C9        EF 9C 85
F3       CA        EF 9C 86
F4       CB        EF 9C 87
F5       CC        EF 9C 88
F6       CD        EF 9C 89
F7       CE        EF 9C 8A
F8       CF        EF 9C 8B
F9       D0        EF 9C 8C
F10      D1        EF 9C 8D
F11      D2        EF 9C 8E
F12      D3        EF 9C 8F
F13                EF 9C 90
F14                EF 9C 91
F15                EF 9C 92
F16                EF 9C 93
F17                EF 9C 94
F18                EF 9C 95
F19                EF 9C 96
CLEAR       
DEL      7F        7F
fn+BS              7F   
       
CTRL+@   00        00
CTRL+A   01        01
CTRL+B   02        02
CTLR+C   03        03
CTRL+D   04        04
CTRL+E   05        05
CTRL+F   06        06
CTRL+G   07        07
CTRL+H   08        08
CTRL+I   09        09
CTRL+J   0A        0A
CTRL+K   0B        0B
CTRL+L   0C        0C
CTRL+M       
CTRL+N   0E        0E
CTRL+O   0F        0F
CTRL+P   10        10
CTRL+Q   11        11
CTRL+R   12        12
CTRL+S   13        13
CTRL+T   14        14
CTRL+U   15        15
CTRL+V   16        16
CTRL+W   17        17
CTRL+X   18        18
CTRL+Y   19        19
CTRL+Z   1A        1A
CTRL+[   1B        1B
CTRL+\   1C        1C
CTRL+]   1D        1D
CTRL+^   1E        1E
CTRL+_   1F        1F


In addition to the above, the Mac also produces various ASCII strings then keys are pressed together with the OPTION or OPTION+SHIFT keys. You can easily find out what it sends for such key combinations by turning on 'local echo' and looking at the data in hex view.
User avatar
roger
Site Admin
 
Posts: 215
Joined: Fri Apr 24, 2009 12:41 am

Re: wish for Send String

Postby kondou » Thu May 15, 2014 6:51 am

Thank you very much.

I works anyway, but there is still one problem left. Sending by "shift+enter" often doesn't work. Keyboard reassignment always appends "shift+enter" at the end of data to send to the device, but Send String often ignores "shift+enter". For the confirmation, I tried to append "shift+enter+'A'" instead to see if 'A' appears at the end of data in the window, and it's always showed. So, I think "shift+enter" is sent to Sent String, but ignored.

As for control over ASCII character, there is no such interface with that device except for ASCII characters. All other keys like F1, ESC, Control, etc. need hex data.
kondou
 
Posts: 5
Joined: Mon May 12, 2014 9:05 pm

Re: wish for Send String

Postby roger » Thu May 15, 2014 9:04 am

Hi,

shift+ENTER is captured by the 'Send String' window and is translated in to a 'Send' button press, i.e. it is not sent through the serial port. You can adjust the connection options (Transmit/Send String Options) to terminate the string being sent with whatever string you want.

Too bad you can't change the mapping on your device.

Do you know how to use AppleScript? As you may know, the Mac version of CoolTerm supports AppleScript. Thus, you could have an AppleScript that captures keystrokes and translates them to the ASCII codes you need and then send them to CoolTerm. I'm not an experienced AppleScript user, i.e. I wouldn't be able to tell you how to capture keystrokes in an AppleScript, but the examples that are included with CoolTerm demonstrate how to control CoolTerm via AppleScript.
User avatar
roger
Site Admin
 
Posts: 215
Joined: Fri Apr 24, 2009 12:41 am

Re: wish for Send String

Postby kondou » Thu May 15, 2014 7:45 pm

Yes, I understand the purpose of shift+enter. What I meant to say was the hex data except shift+enter was not often sent even with shift+enter.

As for AppleScript, I don't have any experience, but it looks like a little bit over loaded process for my purpose, since the script needs to be invoked for each keystroke.

Can CoolTerm handle non-ascii character? Last night, I tried to put non-ascii data, which means 0x80 to 0xff, but CoolTerm could not accept. It looks like ignoring these data. If CoolTerm can also handle these data in the main window, I don't need to use Send String nor shift+enter.
--
Katsuhiro Kondou
kondou
 
Posts: 5
Joined: Mon May 12, 2014 9:05 pm

Re: wish for Send String

Postby roger » Fri May 16, 2014 12:15 pm

I'm not sure why you are experiencing issues. I have tested the 'Send String' feature thoroughly, and pressing Shift+Enter always sends the data in the window. However, you have to make sure that the 'Send String' window that contains the data you wish to send is in the foreground (i.e. is the active window).

Yes, CoolTerm can handle non-ASCII characters. If you enter values such as 00 80 FF in the 'Send String' window (in hex mode) it will be properly sent. However, you have to be careful with switching between plain and hex while you have non-ascii characters in the 'Send String' window as the OS tries to render the non-ascii characters based on certain character encodings. Thus, if you have something like 00 80 FF in hex mode and then switch to plain and then back to hex, you may end up with different ASCII codes. if you are using non-standard ASCII characters, it's best to remain in hex mode in order to not compromise the data. I'm current working on a solution to address this. I'm hopeful that I will be able to fix this in the next release.
User avatar
roger
Site Admin
 
Posts: 215
Joined: Fri Apr 24, 2009 12:41 am

Re: wish for Send String

Postby kondou » Fri May 16, 2014 5:14 pm

If you can try following private.xml for KeyRemap4MacBook, you can reproduce what I experience by just tapping 'a' several times. In this situation, TX lamp in the main window does not blink. I also confirm that it certainly blinks by clicking Send button in Send String window.

<?xml version="1.0"?>
<root>
<appdef>
<appname>COOLTERM</appname>
<equal>org.the-meiers.coolterm</equal>
</appdef>

<item>
<name>a for CoolTerm</name>
<identifier>private.app_coolterm_a</identifier>
<only>COOLTERM</only>
<autogen>--KeyToKey-- KeyCode::A, ModifierFlag::NONE, KeyCode::A, ModifierFlag::COMMAND_L, KeyCode::KEY_6, KeyCode::KEY_1, KeyCode::ENTER, ModifierFlag::SHIFT_L, Option::NOREPEAT</autogen>
</item>

</root>

In the previous my message, I meant to say in the "main window" not Send String window. If CoolTerm can handle non-ascii character in the main window, it'd be much helpful for me.
kondou
 
Posts: 5
Joined: Mon May 12, 2014 9:05 pm

Re: wish for Send String

Postby roger » Thu Jun 12, 2014 8:49 am

The only non-standard-ASCII characters the main window can handle are the ones in the list above using certain key-combinations. For everything else you will need to use the Send Text window.
User avatar
roger
Site Admin
 
Posts: 215
Joined: Fri Apr 24, 2009 12:41 am


Return to Support

Who is online

Users browsing this forum: No registered users and 1 guest

cron