Showing posts with label Linux. Show all posts
Showing posts with label Linux. Show all posts

Monday, February 08, 2016

LittleArduinoProjects#174 USB LED Notifiers

So four of these USB Webmail Notifier devices turned up in a dusty cupboard
in the office.

A quick tear-down shows they contain a super-simple circuit - just a
SONiX Technology SN8P2203SB 8-Bit microcontroller that handles the USB protocol and drives an RGB LED. The SN8P2203SB is an old chip phased out 2010年04月30日, superseded by the SN8P2240. They have a supremely primitive USB implementation - basically mimicking a very basic USB 1.0 HID device.

A quick google reveals quite a bit of old code lying around for various projects using devices like this. Most seem to use libusb for convenience - and often 0.1 legacy libusb that. As I'm mainly on MacOSX, the code is not much use since Apple no longer allows claiming of HID devices
and the libusb team decided not to try to get around that.

So to bring things up-to-date, I wrote a simple demo using hidapi
and things all work fine - see the video below.

Now I just need to ponder on good ideas for what to do with these things!

As always, all all notes, schematics and code are in the Little Arduino Projects repo on GitHub.

[フレーム]
(追記) (追記ここまで)

Sunday, March 25, 2007

Who's bound to that port?

Recently wanted to track down the details of the process that had a specific port open. I checked out the O'Reilly Linux Server Hacks book, and hack #56 was pretty much what I wanted. I scriptified it somewhat as follows. Note that this only looks at tcp:
#!/bin/bash
port=1ドル
procinfo=$(netstat --numeric-ports -nlp 2> /dev/null | grep ^tcp | grep -w ${port} | tail -n 1 | awk '{print 7ドル}')

case "${procinfo}" in
"")
echo "No process listening on port ${port}"
;;
"-")
echo "Process is running on ${port}, but current user does not have rights to see process information."
;;
*)
echo "${procinfo} is running on port ${port}"
ps -uwep ${procinfo%/*}
;;
esac

As you can see, this works by getting a little bit of process info from netstat, then using ps to get the full details. Download the script here: whosOnPort.sh
(追記) (追記ここまで)

Wednesday, January 17, 2007

Generating a temp filename in Bash

Here's a function that simplifies the process of generating temporary filenames in shell scripts (I use bash). This function will generate a temporary filename given optional path and filename prefix parameters. If the file happens to already exist (a small chance), it recurses to try a new filename.

It doesn't cleanup temp files or anything fancy like that, but it does have the behaviour that if you never write to the temp file, it is not created. If you don't like that idea, touch the file before returning the name.

This procedure demonstrates the use of variable expansion modifiers to parse the parameters, and the $RANDOM builtin variable.

function gettmpfile()
{
local tmppath=${1:-/tmp}
local tmpfile=2ドル${2:+-}
tmpfile=$tmppath/$tmpfile$RANDOM$RANDOM.tmp
if [ -e $tmpfile ]
then
# if file already exists, recurse and try again
tmpfile=$(gettmpfile 1ドル 2ドル)
fi
echo $tmpfile
}

By default (with no parameters specified), this function will return a random filename in the /tmp directory:

[prompt]$ echo $(gettmpfile)
/tmp/324003570.tmp


If you specify a path and filename prefix, these are used to generate the name:
[prompt]$ echo $(gettmpfile /my_tmp_path app-tmpfile)
/my_tmp_path/app-tmpfile-276051579.tmp
(追記) (追記ここまで)

Friday, February 03, 2006

Time to upgrade: Linux on Dell 9150

Just recently I bit the bullet - the PCs I had at home no longer had the horsepower (memory mainly) to run the stuff I wanted (Oracle mainly). So I gave myself an early birthday present - a Dell 9150 with the Pentium D processor and 4Gb RAM. Very nice box - running the pre-installed XP was a scream.

The 250Gb HDD came fully allocated for Windows, but my intention was to get it dual booting Linux. There were a few issues, but nothing a few days of messing around and downloading/cutting CDs couldn't fix.

First, to repartition the HDD I used qtparted from a Knoppix boot CD. This worked with no problems at all - Knoppix even booted into a high resolution display and I was able to knock the XP partition down to 50Gb without reinstalling.

Things weren't so straightforward when I started the Linux install, where I was planning Red Hat. I first tried RHEL WS 4 and got nowhere because the installer booted into a graphics mode that the machine couldn't display. I couldn't be bothered persisting because I was really more motivated to go RHEL AS 3 (for compatibility with other systems I'm involved with). I had some update 1 CDs on hand (old I know), but nothing to lose so I proceeded to install. Bad idea - I had driver problems with everything from the Dell USB keyboard (only recognised after plugging/unplugging after boot, and always kicked kudzu into action); USB support in general; the Intel Pro100/1000 NIC (not supported by the e1000 driver); and the display driver (ATI Rage x600).

So nothing to do but spend (quite) a few hours downloading update 6. Luckily this proved to be worthwhile effort - after installing most of the issues are resolved. I still needed to update the e1000 driver, and my display is still running VESA compatible mode but that's OK for me since when booted into Linux I'm mainly just using it as a server. If I want the graphics, sound etc then that usually means I've booted back into XP to dive into Age of Empires III or somesuch;-)

So overall - I'm really happy with the 9150, although I must say where there were a few moments while dealing with Dell's terrible support for Linux on the desktop machines that I was wondering if I made the right buying decision. Dell really should get their act together in terms of supporting Linux on the "consumer" range.

Friday, November 25, 2005

OCFS is making it into the Linux kernel according to the interview with Andrew Morton on kernel development in Linux Format. There's an interesting discussion of this activity with Oracle's Wim Coekaerts in the Inside Oracle's Linux Projects podcast.

Friday, July 02, 2004

Ucase names on Win2k partition going lcase under Linux

Hmm, mounted a Windows 2000 FAT32 partition under linux, but I find that any 8.3 name that is all uppercase on windows is appearing as all lowercase under Linux. Mixed case names are handled properly. Not a major issue until you try and do something like point gcvs at a cvs repository on the vfat partition .. and it can't find the "CVSROOT" directory (since it appreas as "cvsroot").
There are some references on the web that indicate the "check=s" vfat mount option might help, but that does not do the trick for me. A bit of testing later, and what I can report is that the "shortname=winnt" is what is needed. For example:
[root@home #] mount -t vfat -o ro,shortname=winnt /dev/hda1 /mnt/win2k
[root@home #] ls -l /mnt/win2k/MyCVS
total 56
drwxr-xr-x 3 root root 8192 Jun 5 2003 CVSROOT
drwxr-xr-x 11 root root 8192 Sep 6 2003 MyConfig
drwxr-xr-x 35 root root 8192 Jun 5 2003 MyDev
drwxr-xr-x 26 root root 8192 Oct 9 2003 Testers

Ref
Using VFAT

Thursday, July 01, 2004

Red Hat Linux and Oracle 10g installation

Just installed Oracle 10.1.0.2 on my RHEL 3 machine.

I used Werner Puschitz' installation guide, which I found very useful in conjunction with the Oracle Database Quick Installation Guide 10g for Linux
Subscribe to: Comments (Atom)

AltStyle によって変換されたページ (->オリジナル) /