Article View: fj.sys.sun
Article #13233Re: Blinking LED(Re: OpenWindows on SPARC station ELC)
From: Ryouji Hasegawa
Date: Mon, 30 Nov 1992 06:52
Date: Mon, 30 Nov 1992 06:52
147 lines
4384 bytes
4384 bytes
$@$3$s$K$A$O!#D9C+@n!w1~MQ%7%9%F%`It!%Cf1{EE;R$G$9!#(J
In article <NAG.92Nov21030554@packard.mtl.t.u-tokyo.ac.jp>, nag@mtl.t.u-tokyo.ac.jp (Kenji Nagahashi) writes:
> $@D966!wElBg$G$9(J
>
> $@$&$A$G$b$h$/$=$&$$$&>I>u$,=P$k$N$G(J($@$d$O$j(JELC$@$KB?$$(J)$@2r=|MQ$N#C%W%m%0%i(J
> $@%`$r:n$j$^$7$?!#%j%V!<%H$h$j$O$^$7$G$9(J (^^)
$@;d$N$O%-!<%\!<%I$N%?%$%W$rD4$Y$k%3%^%s%I$r:n$k$D$$$G$K!"(J
$@$*M7$S$G:n$C$?%W%m%0%i%`$G$9!#(J:-)
$@%j%;%C%H$O$7$^$;$s!#(J
$@$/$o$7$/$O!"(Jkb(4M)$@$N%^%K%e%"%k$H(J /usr/include/sundev/kbd.h$@$r8+$F2<$5$$(J :-)
------ $@$3$3$+$i(J -------- $@$3$3$+$i(J ------- $@$3$3$+$i(J ------------
/*
ledloop : keyboard led loop
*/
static char _VER_[] = "@(#)ledloop Ver 1.01 by R.Hasegawa 1992-11-30";
#include <stdio.h>
#include <fcntl.h>
#include <sys/types.h>
#include <sys/stream.h>
#include <sys/stropts.h>
#include <sundev/kbio.h>
#include <sundev/kbd.h>
#ifndef KIOCLAYOUT
#define KIOCLAYOUT _IOR(k, 20, int)
struct kiockeymap {
int kio_tablemask; /* Translation table (one of: 0, CAPSMASK,
SHIFTMASK, CTRLMASK, UPMASK, ALTGRAPHMASK) */
u_char kio_station; /* Physical keyboard key station (0-127) */
u_short kio_entry; /* Translation table station's entry */
char kio_string[10]; /* Value for STRING entries (null terminated) */
};
#endif
#ifndef KB_SUN4
#define KB_SUN4 0x04 /* Type 4 Sun keyboard */
#endif
#ifndef KB_SUN5
#define KB_SUN5 0x05 /* Type 5 Sun keyboard */
#endif
#ifndef KB_SUN4J
#define KB_SUN4J 0x14 /* SunOS Type4 Japanese keyboard */
#endif
#define ON 1
#define OFF 0
main(argc,argv)
int argc;
char *argv[];
{
int kbd_fd;
int key_type, dip_sw;
char led, oldled;
int loop;
int i;
struct kiockeymap key;
loop = 10;
if( argc > 1 ){
if( argv[1][0]=='-' && argv[1][1]=='l' )
if( argc >2 )
loop = atoi(argv[2]);
}
if( ( kbd_fd = open("/dev/kbd",O_RDONLY) ) == NULL ){
fprintf(stderr,"Can not open /dev/kbd\n");
exit(-1);
}
ioctl(kbd_fd, KIOCTYPE, &key_type);
if( ioctl(kbd_fd, KIOCLAYOUT, &dip_sw) < 0 ){
/* SunOS 4.0.X */
if (key_type == KB_SUN3) {
struct kiockey key;
key.kio_tablemask = 0;
key.kio_station = 118;
if (ioctl(kbd_fd, KIOCGETKEY, &key)) {
perror( "ioctl KIOCGETKEY" );
exit(-1);
}
if (key.kio_entry != 0xa2) {
key_type = KB_SUN4;
}
}
}else{
/* SunOS 4.1.X */
if (key_type == KB_SUN4 && dip_sw == 0x20) {
key_type = KB_SUN4J;
}
}
if( (key_type != KB_SUN4) && (key_type != KB_SUN4J) ){
fprintf(stderr,"Not type4 key board.\n");
close(kbd_fd);
exit(key_type);
}
ioctl(kbd_fd, KIOCGLED, &oldled); /* save LED status */
for(i=0; i < 5; i++){
led = LED_CAPS_LOCK;
ioctl(kbd_fd, KIOCSLED, &led);
waitloop(loop);
led = LED_COMPOSE;
ioctl(kbd_fd, KIOCSLED, &led);
waitloop(loop);
led = LED_SCROLL_LOCK;
ioctl(kbd_fd, KIOCSLED, &led);
waitloop(loop);
led = LED_NUM_LOCK;
ioctl(kbd_fd, KIOCSLED, &led);
waitloop(loop);
}
#ifdef POP_LED_STATUS
ioctl(kbd_fd, KIOCSLED, &oldled);
#else /* !POP_LED_STATUS */
led = 0;
ioctl(kbd_fd, KIOCSLED, &led);
#endif /* !POP_LED_STATUS */
exit(key_type);
}
waitloop(loop)
int loop;
{
int i,j;
for(i = 0; i < loop; i++)
for(j = 0; j < 10000; j++)
;
}
------ $@$3$3$^$G(J -------- $@$3$3$^$G(J ------- $@$3$3$^$G(J ------------
--
-----------------------------------------------------------------------
$@Cf1{EE;R3t<02q<R(J $@1~MQ%7%9%F%`;v6HIt(J $@D9C+@n5};J(J (hasegawa@cec.co.jp)
-----------------------------------------------------------------------
Technical Details
Message-ID:
<2444@cecgw.cec.co.jp>Path:
arc1-ca.pugleaf.net!sparky!uunet!ccut!sh.wide!wnoc-tyo-news!sranha!cecgw!hasegawaReferences:
<h3AUI.wakai@shpcsl.sharp.co.jp> <NAG.92Nov21030554@packard.mtl.t.u-tokyo.ac.jp>Show Full Headers
Complete Article Headers
X-Google-Language: Japanese,JIS X-Google-Thread: fcfb5,d28d15996af8e82b X-Google-Attributes: gidfcfb5,public X-Google-ArrivalTime: 1992-11-29 23:08:17 PST Path: arc1-ca.pugleaf.net!sparky!uunet!ccut!sh.wide!wnoc-tyo-news!sranha!cecgw!hasegawa From: hasegawa@cec.co.jp (Ryouji Hasegawa) Newsgroups: fj.sys.sun Subject: Re: Blinking LED(Re: OpenWindows on SPARC station ELC) Message-ID: <2444@cecgw.cec.co.jp> Date: 30 Nov 92 06:52:59 GMT References: <h3AUI.wakai@shpcsl.sharp.co.jp> <NAG.92Nov21030554@packard.mtl.t.u-tokyo.ac.jp> Sender: news@cec.co.jp Distribution: fj Organization: Chuo Electronics Co., Ltd. Tokyo, Japan. Lines: 146 Nntp-Posting-Host: yuri.cec.co.jp