inmbolmie / 5250_usb_converter

Converter to plug an IBM 5251 terminal to a Linux PC via USB emulating a VT52 terminal
GNU General Public License v3.0
34 stars 6 forks source link

Caps lock indicator does not appear on 3476 #13

Closed dcoshea closed 8 months ago

dcoshea commented 8 months ago

This code doesn't actually show any indicator on a 3476 when caps lock is enabled:

                self.indicatorsByte = self.indicatorsByte | 0x10
                self.transmitCommand(WRITE_DATA_LOAD_CURSOR_INDICATORS,
                                     self.destinationAddr,
                                     [self.indicatorsByte])
            else:
                self.indicatorsByte = self.indicatorsByte & 0xEF
                self.transmitCommand(WRITE_DATA_LOAD_CURSOR_INDICATORS,
                                     self.destinationAddr,
                                     [self.indicatorsByte])

Based on https://bitsavers.org/pdf/ibm/5250_5251/5250_Information_Display_System_to_S36_S38_AS400_System_Units_Product_Attachment_Information_198910.pdf section 2.4.16.1 "Discrete Indicators Data Word" (p65) and my understanding of the bit ordering from experimenting with the txindicatorsbyte command, this is toggling the "Katakana shift" bit. Using a mask of 0x20 instead would turn on the "Keyboard shift" bit which causes a ⇧ to appear on the 3476's status line. From looking at photos online I gather that 5251s have an indicator for that too (although I can't be sure since I didn't see any in English, or at least any that were in focus!), so I assume it's probably supported by all 5250-like terminals, whereas I'm assuming the katakana shift bit might not be supported by many?

For what it's worth, https://bitsavers.org/pdf/ibm/5250_5251/SY31-0461-0_5251_Display_Station_Model_11_Maintenance_Information_Dec77.pdf p4-9 says that indicator "indicates that the display station is in upper (numeric) keyboard shift" so I'm not sure what it's actually meant for.

5250_Information_Display_System_to_S36_S38_AS400_System_Units_Product_Attachment_Information_198910.pdf sections 15 and 16 show that the 3476 and 3477 respectively both support additional indicators written using a separate command, and that set includes an actual "Caps Lock" indicator (which shows up as an "A"), but some work would obviously need to be done to detect the station type before trying to using that one, or it would need to be a configuration option.

dcoshea commented 8 months ago

Just to be clear, it's not just an academic exercise, as I'm not used to having Caps Lock and Ctrl swapped, so I'm often inadvertently in Caps Lock mode :laughing:

inmbolmie commented 8 months ago

Hi, thanks for the report, I have added an "advanced mode" where the caps lock indicator is enabled as you described, and it appears as an 'A' on my 3488 display when enabled. The intention in the future would be to use the now documented command to get the terminal variants identifiers to enable automatically features that only apply to a particular terminal or terminals.

To enable advanced mode you can start the terminal with a command like

python3 5250_terminal.py 0::::1

...where that last 1 is enabling this mode.

I know it is a little clumsy now but this way won't break anything for other users.

Also fixed the 0x10 for 0x20 on the regular mode, I don't know if it was a typo or I simply didn't care as long as any light would be fine on a 5251 to indicate the caps lock state.

Best regards