LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   Write a udev rule with 2 actions (https://www.linuxquestions.org/questions/linux-software-2/write-a-udev-rule-with-2-actions-4175474325/)

Quakeboy02 08-22-2013 05:49 PM

Write a udev rule with 2 actions
 
I have an agilent 82357b clone. The linux-gpib software from sourceforge comes with hotplug stuff. I found a site that has an example udev for an NI device, but this one is a bit different. You have to load the firmware twice, and both times it changes the usb address/id (whatever it's called).

For example: Say that the device is this:
Code:

Bus 002 Device 031: ID 0957:0718 Agilent Technologies, Inc.
When you run install the firmware with fxload it becomes
Code:

Bus 002 Device 032: ID 0957:0718 Agilent Technologies, Inc.
But you need to run fxload a second time and it becomes
Code:

Bus 002 Device 033: ID 0957:0718 Agilent Technologies, Inc.
How can I change "99-linux_82357a.rules" so that it runs "/lib/firmware/agilent_82357a" a second time with the updated DEVNAME? (Assuming that's the file I need to change.)

NOTE: The origin of /lib/firmware file assumes that the device first appears with idProduct=="0715", but I'm not seeing that with mine.


Here is what I have so far:

/etc/udev/rules.d/99-linux_82357a.rules
Code:

SUBSYSTEM=="usb", ACTION=="add", ENV{DEVTYPE}=="usb_device", ATTR{idVendor}=="0957", ATTR{idProduct}=="0718", MODE="660", GROUP="gpib", SYMLINK+="usb_gpib"
SUBSYSTEM=="usb", ACTION=="add", ENV{DEVTYPE}=="usb_device", ATTR{idVendor}=="0957", ATTR{idProduct}=="0718", RUN+="/lib/udev/agilent_82357a"
KERNEL=="gpib[0-9]*", ACTION=="add", MODE="660", GROUP="gpib"

/lib/udev/agilent_82357a
Code:

#!/bin/sh

GPIB_CONFIG_OPTIONS="--minor 0"
DATADIR=/lib/firmware
FXLOAD=/sbin/fxload
GPIB_CONFIG=/usr/local/sbin/gpib_config
FXLOAD_OPTIONS=

PATH=$PATH:/sbin:/usr/sbin:/usr/local/sbin:/bin:/usr/bin:/usr/local/bin
FIRMWARE=
SS_LOADER=

# pre-renumeration device IDs
case $PRODUCT in
# 82357a with firmware already loaded
957/107/*)
        $GPIB_CONFIG $GPIB_CONFIG_OPTIONS
        ;;

# 82357a without firmware
957/7/*)
        FIRMWARE=$DATADIR/agilent_82357a/82357a_fw.hex
        SS_LOADER=$DATADIR/agilent_82357a/82357a_fw.hex
        ;;

# 82357b with firmware already loaded
957/518/*)
        $GPIB_CONFIG $GPIB_CONFIG_OPTIONS
        ;;

# 82357b without firmware
957/718/*)
        FIRMWARE=$DATADIR/measat_releaseX1.8.hex
        SS_LOADER=$DATADIR/measat_releaseX1.8.hex
        FXLOAD_OPTIONS="-t fx2"
        ;;

esac

# quit unless we were called to download some firmware
if [ "$FIRMWARE" = "" ]; then
    # OR:  restructure to do other things for
    # specific post-renumeration devices
    exit 0
fi

# missing firmware?
if [ ! -r $FIRMWARE ]; then
    if [ -x /usr/bin/logger ]; then
        /usr/bin/logger -t $0 "missing $FIRMWARE for $PRODUCT ??"
    fi
    exit 1
fi

# missing second stage loader?
if [ ! -r $SS_LOADER ]; then
    if [ -x /usr/bin/logger ]; then
        /usr/bin/logger -t $0 "missing $SS_LOADER for $PRODUCT ??"
    fi
    exit 1
fi

# missing fxload?
if ! which $FXLOAD; then
    if [ -x /usr/bin/logger ]; then
        /usr/bin/logger -t $0 "missing $FXLOAD ??"
    fi
    exit 1
fi

if [ -x /usr/bin/logger ]; then
    /usr/bin/logger -t $0 "load $FIRMWARE for $PRODUCT to $DEVICE"
fi

$FXLOAD -v $FSLOAD_OPTIONS -D ${DEVNAME} -I $FIRMWARE -s $SS_LOADER


rootboy 08-24-2013 05:00 PM

One of these?

http://www.home.agilent.com/en/pd-10...?&cc=US&lc=eng

This isn't much of an answer to your udev rules question, but here is another source for GPIB interfaces:

https://launchpad.net/~v-kukol/+archive/gpib-testing


Whatcha plugging the GPIB end into? :) I've got a few HP/Agilent LA's (a 16500b and a couple of 16702a's) here.

Quakeboy02 08-25-2013 04:44 PM

Hi rootboy,

I've got a couple of counters, an SA, and a voltmeter that I'd like to hookup. I'm not sure what direction I'm going to have to take, as linux-gpib just doesn't like my adapter on Debian. I tried setting up Scientific Linux in a virtual box and installing both linux-gpib and NI-VISA, but I clearly haven't cast the appropriate spells, because that's not working either. This will take a back seat for awhile, as I have other projects, but eventually I'm going to have to find a way to make it work. I'll checkout that link to the fork of linux-gpib and see if it has anything to offer.

rootboy 08-26-2013 09:24 PM

This is the one that I will be getting: http://prologix.biz/gpib-ethernet-controller.html. I'm not even going to attempt to get the USB version going.

Try over at the "hp_agilent_equipment" group on Yahoo. Someone there might know how to get it working. With all of this test equipment floating around, you would think that one of us would have hooked up and figured it out by now. LOL

Quakeboy02 08-26-2013 10:25 PM

I've been in the hp_agilent_equipment group for awhile, and no-one seems interested in helping setup this device on linux. The linux_gpib group asked me a couple of questions, but didn't respond with any help after I posted a long reply. I think it's effectively a moribund group.

I've setup a Scientific Linux virtualbox and tried to load ni-visa on it with mixed results. The software can detect the controller, but can't see the counter I have it plugged into. SL doesn't look like a bad distro, and I'd even consider jumping ship from Debian if I could just get this working. =) Loading the software is always the easiest part. It's the configuration bits and bobs that always kill you.

So, what I have is the sourcecode for linux-gpib and a seemingly very steep learning curve for ScientificLinux plus NI-VISA. I'm going to play with SL for awhile, but if I can't figure out how to see an instrument soon, I'm just going to go play with the sourcecode for linux-gpib. It's been a very long time since I played with linux device drivers, but that might be the most productive route.

As to my original question. I had figured out a way to do it in a manually run script before I posted this question. I'll probably just meld that script with the udev script and call it good, if I can get somewhere with the linux-gpib. My manual script works so it's very low on my priority list.

Added:

Oh, and the Prologix stuff looks good. There's no complicated interface: just send the commands and it works. I took a chance on something less than half that price and I'm paying for it with my time.

rootboy 08-26-2013 11:04 PM

Quote:

Originally Posted by Quakeboy02 (Post 5016608)
I've been in the hp_agilent_equipment group for awhile, and no-one seems interested in helping setup this device on linux. The linux_gpib group asked me a couple of questions, but didn't respond with any help after I posted a long reply. I think it's effectively a moribund group.

The problem with the group (as I see it) is that it is too generalized. It really should be broken up into sub-groups where things are a bit more focused. Waaay too much traffic...


Quote:

Originally Posted by Quakeboy02 (Post 5016608)
I've setup a Scientific Linux virtualbox and tried to load ni-visa on it with mixed results. The software can detect the controller, but can't see the counter I have it plugged into. SL doesn't look like a bad distro, and I'd even consider jumping ship from Debian if I could just get this working. =) Loading the software is always the easiest part. It's the configuration bits and bobs that always kill you.

That's why I have partition after partition after partiton available on this box. It isn't a big deal to set up a distro for testing. I am distro agnostic, so I will try anything once.


Quote:

Originally Posted by Quakeboy02 (Post 5016608)
So, what I have is the sourcecode for linux-gpib and a seemingly very steep learning curve for ScientificLinux plus NI-VISA. I'm going to play with SL for awhile, but if I can't figure out how to see an instrument soon, I'm just going to go play with the sourcecode for linux-gpib. It's been a very long time since I played with linux device drivers, but that might be the most productive route.

You are a better man than I, Gunga Din. :)

I am a Controls Engineer, aka, a PLC jockey. I couldn't spell "C" if you told me it was settled in between the "B" and the "D" in the alphabet... :)


Quote:

Originally Posted by Quakeboy02 (Post 5016608)
As to my original question. I had figured out a way to do it in a manually run script before I posted this question. I'll probably just meld that script with the udev script and call it good, if I can get somewhere with the linux-gpib. My manual script works so it's very low on my priority list.

Yeah, if it works, don't fight it.


Quote:

Originally Posted by Quakeboy02 (Post 5016608)
Added:

Oh, and the Prologix stuff looks good. There's no complicated interface: just send the commands and it works. I took a chance on something less than half that price and I'm paying for it with my time.

Something that I learned *not* to do a long time ago. I work a 50 - 60 hour week normally, and I find myself with more disposable income than time (maybe not a *huge* amount of disposable income, but still more than I have of time). So any device that doesn't perform either gets donated, or parted out. I really enjoy firing up my xytronic solder/desolder station and taking out my frustrations on a miscreant board. :)

As for your SA, I'm envious. We got a Rigol SA here at work (which I suppose I could take home and play with if I like), and while it is nice, it ain't a HP/Agilent...

And my SA is coming in from Israel, it's a, umm, Afedri SDR (if you squint real hard it kinda-sorta looks like a SA :) )

Quakeboy02 08-26-2013 11:44 PM

"Something that I learned *not* to do a long time ago. I work a 50 - 60 hour week normally, and I find myself with more disposable income than time"

I've been disabled for quite some time, so I have to manage things in the other direction. =)

And don't be too jealous of my old gear, especially my SA, which is an 8558B. I've got a 5334B, a 5335A, an 853A with the 8558B plugin, an 8640B, an 8444A, and a nice 3456A DMM. The SA's not much, but it satisfies what few needs I have for it. About half of this was received not working, so I traded my time for the cost difference. But, it's a good, enjoyable hobby, and keeps me occupied, rather than watching soap operas. LOL Why couldn't I have had some of this stuff back in the day, instead of all the Heathkit stuff I've owned? =)

rootboy 08-28-2013 11:47 PM

Quote:

Originally Posted by Quakeboy02 (Post 5016635)
"Something that I learned *not* to do a long time ago. I work a 50 - 60 hour week normally, and I find myself with more disposable income than time"

I've been disabled for quite some time, so I have to manage things in the other direction. =)

I am sorry to hear that. Another long day for me (12 hours), but that's better than not being able to work.


Quote:

Originally Posted by Quakeboy02 (Post 5016635)
And don't be too jealous of my old gear, especially my SA, which is an 8558B.

Yeah, I saw it in the the Radio Museum: http://www.radiomuseum.org/r/hewlett...r_hp8558b.html Looks a lot like the gear that we had in High school in the 70's. :)

Since you are into antiques, can I interest you in a Nicolet npc-764 logic analyzer? As far as I know, it even works (it was tossed in as part of a deal for a Tek quad trace scope. I've never turned it on). PM me with an address of where you want it sent and it's yours.


Quote:

Originally Posted by Quakeboy02 (Post 5016635)
I've got a 5334B, a 5335A, an 853A with the 8558B plugin, an 8640B, an 8444A, and a nice 3456A DMM. The SA's not much, but it satisfies what few needs I have for it. About half of this was received not working, so I traded my time for the cost difference. But, it's a good, enjoyable hobby, and keeps me occupied, rather than watching soap operas. LOL Why couldn't I have had some of this stuff back in the day, instead of all the Heathkit stuff I've owned? =)

Ain't that the truth! :)

Quakeboy02 08-29-2013 05:22 AM

Thanks for the offer, but I don't know where I'd put it.

rootboy 08-29-2013 10:00 PM

Quote:

Originally Posted by Quakeboy02 (Post 5018105)
Thanks for the offer, but I don't know where I'd put it.

I can't believe that you are going to pass up on the opportunity to sharpen your CP/M skills. You know, just like DOS, only lamer... :)


All times are GMT -5. The time now is 01:34 AM.