Sunday, February 22, 2015

Windows - The object invoked has disconnected from its client (Partial Fix)

I got this particular error message:
"The object invoked has disconnected from its client"
when trying to log into my Windows 8.1 machine locally.

This error is particularly debilitating because I cannot log in to my machine even from confirmed accounts that I used either for day to day tasks or administrative tasks. The culprit turns out to be a USB flash disk left plugged on one of the machine's USB socket. The fix is very simple, just remove the "offending" USB flashdisk and then all-is-well.
The USB flash disk in question contains a valid UEFI bootable OS along with the mandatory EFI partition to boot an UEFI-compliant OS. It seems to be some kind of check in Windows "chain of trust" detects this "irregularity" as breaking the "chain of trust" when Windows boot. Therefore, Windows decided that this is a malicious login attempt and blocks access into it. However, somehow the protection mechanism ends up with very uninformative message.


I list my analysis as "Partial Fix" because it works for my particular Windows 8.1 setup but might not work for other Windows versions.

Intel PCH (Haswell) Sound (ALSA) Problem and Fix for Arch Linux

The main problem fixed by the method explained here as follows: 
1. The kernel sound modules loaded just fine and able to recognize all sound-related chips just fine.
2. The Intel PCH platform (in my case Haswell) seems to be perfectly fine in loading modules. Moreover, checks via alsautils programs seems to work as well.
3. There's no sound coming out of the analog output. The analog output is usually the ones which a laptop speaker is connected and the one which you put earphone jack into. If you are using HDMI output from your Intel platform. You might not need this fix.

The "hint" that problem exists is usually failure when running:
$ speaker-test
with rather cryptic error message akin to "unable to open XXXX file"

This fix is focused on my Haswell Laptop but it could also work on other Intel systems with PCH as well. The basic idea comes from this post: https://bbs.archlinux.org/viewtopic.php?id=180102. The only different thing is details of the hardware. The basic idea of the fix is: to force ALSA to reorder the module loading so as to make the sound chip controlling the analog output becomes the default output.
This fix ensures that the sound coming out of the default sound device is coming out of the analog output instead of the HDMI output. Anyway, you should have a sort of hint on which PCI device in your machine that controls the analog audio output. Usually, in Intel PCH platform (at least in Haswell), the ones that controls the analog output doesn't connect to the CPU directly, but rather to the PCH because the CPU (i.e. the HDMI device in the CPU chip) only connects to HDMI output. You should consult the system block diagram to ensure about this.

The fix consists of a *.conf file in /etc/modprobe.d. This file instructs the kernel module loader, i.e. the ALSA subsystem to reorder the sound modules so as to make the PCH audio device the "default" one (having index 0). In my case, I name the *.conf file: /etc/modprobe.d/alsa-base.conf. This is the contents of my /etc/modprobe.d/alsa-base.conf:
# Intel PCH
options snd-hda-intel index=0  model=auto vid=8086 pid=9c20
# Intel HDMI 
options snd-hda-intel index=1  model=auto vid=8086 pid=0a0c

The meaning of the module configuration file above is to set PCI device with Vendor IDentifier (VID) 8086 and PID 9C20, i.e. Intel PCH  as the default sound device (with index value set 0). You can find your specific vid and pid with this following command:
$ lspci -nn | grep -i audio
00:03.0 Audio device [0403]: Intel Corporation Haswell-ULT HD Audio Controller [8086:0a0c] (rev 09)
00:1b.0 Audio device [0403]: Intel Corporation 8 Series HD Audio Controller [8086:9c20] (rev 04)

This is the output of aplay -l in my system after I applied the fix:
$ aplay -l
**** List of PLAYBACK Hardware Devices ****
card 0: PCH [HDA Intel PCH], device 0: ALC3239 Analog [ALC3239 Analog]
  Subdevices: 0/1
  Subdevice #0: subdevice #0
card 1: HDMI [HDA Intel HDMI], device 3: HDMI 0 [HDMI 0]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
As you can see, the PCH audio device has become the "default" audio device (card 0). With the fix, speaker-test no longer stops with "unable to open XXXX file" but outputs noise sounds from the speaker. This is an excerpt of speaker-test log from my terminal:
$ speaker-test

speaker-test 1.0.28

Playback device is default
Stream parameters are 48000Hz, S16_LE, 1 channels
Using 16 octaves of pink noise
Rate set to 48000Hz (requested 48000Hz)
Buffer size range from 2048 to 16384
Period size range from 1024 to 1024
Using max buffer size 16384
Periods = 4
was set period_size = 1024
was set buffer_size = 16384
 0 - Front Left
Time per period = 2.657561
 0 - Front Left
Time per period = 2.986723
 0 - Front Left
I hope this also helps those experiencing similar problems out there. Ciao.

Sunday, February 15, 2015

Zsh-Tmux Configuration for (Arch) Linux

I've been doing some testing in order to migrate to use tmux and zsh for my daily work on Linux. This post will show my configuration on both of them. First up is .zshrc:
autoload -U compinit promptinit
compinit
promptinit

# This will set the default prompt to the walters theme
prompt walters

zstyle ':completion:*' menu select
setopt completealiases
setopt HIST_IGNORE_DUPS

alias tmux='tmux -u'

# create a zkbd compatible hash;
# to add other keys to this hash, see: man 5 terminfo
typeset -A key

key[Home]=${terminfo[khome]}
key[End]=${terminfo[kend]}
key[Insert]=${terminfo[kich1]}
key[Delete]=${terminfo[kdch1]}
key[Up]=${terminfo[kcuu1]}
key[Down]=${terminfo[kcud1]}
key[Left]=${terminfo[kcub1]}
key[Right]=${terminfo[kcuf1]}
key[PageUp]=${terminfo[kpp]}
key[PageDown]=${terminfo[knp]}

# setup key accordingly
[[ -n "${key[Home]}"     ]]  && bindkey  "${key[Home]}"     beginning-of-line
[[ -n "${key[End]}"      ]]  && bindkey  "${key[End]}"      end-of-line
[[ -n "${key[Insert]}"   ]]  && bindkey  "${key[Insert]}"   overwrite-mode
[[ -n "${key[Delete]}"   ]]  && bindkey  "${key[Delete]}"   delete-char
[[ -n "${key[Up]}"       ]]  && bindkey  "${key[Up]}"       up-line-or-history
[[ -n "${key[Down]}"     ]]  && bindkey  "${key[Down]}"     down-line-or-history
[[ -n "${key[Left]}"     ]]  && bindkey  "${key[Left]}"     backward-char
[[ -n "${key[Right]}"    ]]  && bindkey  "${key[Right]}"    forward-char
[[ -n "${key[PageUp]}"   ]]  && bindkey  "${key[PageUp]}"   beginning-of-buffer-or-history
[[ -n "${key[PageDown]}" ]]  && bindkey  "${key[PageDown]}" end-of-buffer-or-history


# Finally, make sure the terminal is in application mode, when zle is
# active. Only then are the values from $terminfo valid.
if (( ${+terminfo[smkx]} )) && (( ${+terminfo[rmkx]} )); then
    function zle-line-init () {
  printf '%s' "${terminfo[smkx]}"
 }

 function zle-line-finish () {
  printf '%s' "${terminfo[rmkx]}"
 }
 zle -N zle-line-init
 zle -N zle-line-finish
fi

I lay no claims on this configuration because it's a mix-and-match result of several configuration. Mainly from Arch Linux wiki. It worked without problems though. Next up is .zshenv:
typeset -U path
path=(~/bin $path)
So. Now hopefully you get working zsh configuration. The comments in the config files are self-explanatory. Next up is my .tmux.conf:
#Prefix is Ctrl-a
set -g prefix C-a
bind C-a send-prefix
unbind C-b

# set shell
set -g default-shell /bin/zsh

set -sg escape-time 1
set -g base-index 1
setw -g pane-base-index 1

#Mouse works as expected
setw -g mode-mouse on
set -g mouse-select-pane on
set -g mouse-resize-pane on
set -g mouse-select-window on

setw -g monitor-activity on
set -g visual-activity on

set -g mode-keys vi
set -g history-limit 10000

# y and p as in vim
bind Escape copy-mode
unbind p
bind p paste-buffer
bind -t vi-copy 'v' begin-selection
bind -t vi-copy 'y' copy-selection
bind -t vi-copy 'Space' halfpage-down
bind -t vi-copy 'Bspace' halfpage-up

# extra commands for interacting with the ICCCM clipboard
bind C-c run "tmux save-buffer - | xclip -i -sel clipboard"
bind C-v run "tmux set-buffer \"$(xclip -o -sel clipboard)\"; tmux paste-buffer"

# easy-to-remember split pane commands
bind | split-window -h
bind - split-window -v
unbind '"'
unbind %

# moving between panes with vim movement keys
bind h select-pane -L
bind j select-pane -D
bind k select-pane -U
bind l select-pane -R

# moving between windows with vim movement keys
bind -r C-h select-window -t :-
bind -r C-l select-window -t :+

# resize panes with vim movement keys
bind -r H resize-pane -L 5
bind -r J resize-pane -D 5
bind -r K resize-pane -U 5
bind -r L resize-pane -R 5
Well, this one is also quite self-explanatory. At the very least this provides you with basic command completion among others and tmux that recognize zsh. Also, it remaps C-b to C-a so that it's easier to reach in QWERTY keyboard.
This is how they look like at work:
A bit of explanation on the 'tmux -u' alias. The terminal application that I'm using somehow cannot recognize the vertical line delimiter correctly in tmux unless I force it to assume that it know UTF-8 encoding. If not forced, it will use 'x' as the delimiter which was annoying.

Friday, January 30, 2015

CCSIDs a.k.a Code Pages in IBM PASE for i

It all started with iconv() function in iSeries PASE. I need to figure out how to convert strings back and forth between iSeries PASE and ILE programs. I didn't realize at first that there were TWO instead of one libiconv library installed on the iSeries I worked with. One from GNU and one from IBM (the original one). I had to specify the one I intend to use specifically in my Makefile.am as follows:

 pase_to_rpg_string_LDADD = /QOpenSys/QIBM/ProdData/OS400/PASE/lib/libiconv.a

Well, then it turned out, the code page "string" specified for ILE C didn't work out. I found out that the code page string should be as shown here. I'm puzzled as to where that guy found the code page string. Then, I finally found that it was AIX code page specification after all, as this link shows. I reproduce it below, just in case (and hopefully IBM doesn't mind ;).

Table 1. CICS Shortcodes, CCSIDs and code pages that TXSeries for Multiplatforms supports
CICS short code nameCCSIDAIX® and Windows code pageHP–UX code page nameSolaris code page nameDescription
3737IBM-037american_eIBM-037IBMLatin-1 EBCDIC
8859-1819ISO8859-1iso8859_18859Latin-1 ASCII (ISO)
819819ISO8859-1iso8859_18859Latin-1 ASCII (IBM/ISO)
850850IBM-850roman8IBM-850Latin-1 ASCII
437437IBM-437iso8859_1IBM-437Latin-1 (PC) ASCII
930930IBM-930cp930IBM-930Japanese EBCDIC
931931IBM-931japanese_eIBM-931Japanese EBCDIC
939939IBM-939cp939IBM-939Japanese EBCDIC
932932IBM-932sjisja_JP.pckJapanese ASCII
EUCJP954IBM-eucJPeucJPeucJPJapanese ASCII (ISO)
942942IBM-942IBM-942IBM-942Japanese ASCII
943943IBM-943IBM-943IBM-943Japanese ASCII
EUCKR970IBM-eucKReucKReucKRKorean ASCII (ISO)
934934IBM-934IMB-934IBM-934Korean ASCII
944944IBM-944IBM-944IBM-944Korean ASCII
949949IBM-949korean15IBM-949Korean ASCII
933933IBM-933korean_eIBM-933Korean EBCDIC
EUCTW964IBM-eucTWIBM-eucTWeucTWTraditional Chinese
938938IBM-938IBM-938IBM-938Traditional Chinese ASCII
948948IBM-948IBM-948IBM-948Traditional Chinese ASCII
937937IBM-937chinese-t_eIBM-937Traditional Chinese EBCDIC
BIG5950Zh_TW.big5big5zh_TW.BIG5Traditional Chinese BIG5
946946IBM-946IBM-946IBM-946Simplified Chinese ASCII
13811381IBM-1381hp15CNIBM-1381Simplified Chinese ASCII
935935IBM-935chinese-s_eIBM-935Simplified Chinese EBCDIC
EUCN1383IBM-eucCNchinese-s_eeucCNSimplified Chinese ASCII (ISO)
GB180305488GB18030gb18030GB18030Simplified Chinese GB18030
864864IBM-864arabic8IBM-864Arabic ASCII
8859-61089ISO8859-6iso8859_6ISO8859-6Arabic ASCII (ISO)
10891089ISO8859-6iso8859_6ISO8859-6Arabic ASCII (IBM/ISO)
420420IBM-420arabic_eIBM-420Arabic EBCDIC
855855IBM-855IBM-855IBM-855Cyrillic ASCII
866866IBM-866IBM-866IBM-866Cyrillic ASCII
8859-5915ISO8859-5iso8859_5ISO8859-5Cyrillic ASCII (ISO)
915915ISO8859-5iso8859_5ISO8859-5Cyrillic ASCII (IBM/ISO)
10251025IBM-1025IBM-1025IBM-1025Multilingual Cyrillic EBCDIC
869869IBM-869greek8IBM-869Greek ASCII
8859-7813ISO8859-7iso8859_7ISO8859-7Greek ASCII (ISO)
813813ISO8859-7iso8859_7ISO8859-7Greek ASCII (IBM/ISO)
875875IBM-875greek_eIBM-875Greek EBCDIC
856856IBM-856hebrew8IBM-856Hebrew ASCII
8859-8916ISO8859-8iso8859_8ISO8859-8Hebrew ASCII (ISO)
916916ISO8859-8iso8859_8ISO8859-8Hebrew ASCII (IBM/ISO)
424424IBM-424hebrew_eIBM-424Hebrew EBCDIC
273273IBM-273german_eIBM-273Austria, Germany EBCDIC
277277IBM-277danish_eIBM-277Denmark, Norway EBCDIC
278278IBM-278finnish_eIBM-278Finland, Sweden EBCDIC
280280IBM-280italian_eIBM-280Italy EBCDIC
284284IBM-284spanish_eIBM-284Spain, Latin Am.(Sp) EBCDIC
285285IBM-285english_eIBM-285UK EBCDIC
297297IBM-297french_eIBM-297France EBCDIC
500500IBM-500IBM-500IBM-500International latin-1 EBCDIC
871871IBM-871icelandic_eIBM-871Iceland EBCDIC
852852IBM-852IBM-852IBM-852Latin-2 ASCII
8859-2912ISO8859-2iso8859_2ISO8859-2Latin-2 ASCII (ISO)
912912ISO8859-2iso8859_2ISO8859-2Latin-2 ASCII (IBM/ISO)
870870IBM-870IBM-870IBM-870Latin-2 EBCDIC
857857IBM-857turkish8IBM-857Turkey ASCII
8859-9920ISO8859-9iso8859_9ISO8859-9Turkey ASCII (ISO)
920920ISO8859-9iso8859_9ISO8859-9Turkey ASCII (IBM/ISO)
10261026IBM-1026turkish_eIBM-1026Turkey EBCDIC
UTF-81208UTF-8 (only)UTF-8UTF-8Unicode file code set
UCS-21200UCS-2 (only)UCS-2UCS-2Unicode processing code set

So, next time, you code on iSeries PASE, use "IBM-037" (EBCDIC code page) and "ISO8859-1" (ASCII 8-bit) strings to convert back and forth.

I hope this post will somehow save somebody someday.