cd Desktop
[jan@alpha-site Desktop]$ ./hidtest /dev/usb/hiddev0 hiddev open: No such file or directory [jan@alpha-site Desktop]$ ls -l /dev/usb/hid* ls: cannot access /dev/usb/hid*: No such file or directory [jan@alpha-site Desktop]$ lsusb bash: lsusb: command not found hid.c and hidtest exist. Should I be doing this as root? I had a problem a little earlier when I tried to copy/paste post#6. The browser crashed, bug-report popped-up. I restarted the system and then the copy/paste started working again. |
I found a section in one of my manuals on programming, think I'll read it.
|
It seems that you successfully compiled the program so you're very close from actually getting it to work. I checked out the fedora core hiddev support and the device should be there by default but the path to it is a bit different. I used Slackware in my example. Try using /dev/hiddev0 instead of /dev/usb/hiddev0. That should work. Also, please post output from lsusb command and try ls -l /dev/hid* this time. Make sure the scale is connected.
|
I agree that you probably do have a SourceForge entry.
The only remaining "trick" is the USB bit. The piece you probably want to read more about is called hotplug. When you plug-in a device or remove it, the hotplug daemon looks-up information to find out what to do. (In your case, specifically look at /etc/hotplug/usb*.) In your case, this device really isn't privileged and probably won't be used by more than one client, so all you'd really like to do here is to have it set up a nice entry in /dev/input so that your user-application can expect to find the device by a nice name such as pitney_bowes_xyzzy_scale. Beyond that, no system-level driver-stuff is needed: you can read and write to the device as it is. A short user-level library might be a nice touch, with routines like "is there a device attached," "wait so-many seconds for device to be attached," "wait so-many seconds to read the weight," and so on. |
Actually the Pitney-Bowes scale has been working for me for quite a while. I read directly from the raw hiddev as the protocol is trivial - just like I demonstrated in the example. It would be good if hhhansen posted his modifications to the code for Radio Shack scale then the people like yonnieboy wouldn't have to struggle again. We could add the scale recognition and support for different USB scales over unified protocol. I'll open the SF project.
|
Quote:
|
cd Desktop
[jan@alpha-site Desktop]$ gcc -o hidtest -Wall -W hid.c [jan@alpha-site Desktop]$ ./hidtest /dev/hiddev0 hiddev open: Permission denied [jan@alpha-site Desktop]$ ps PID TTY TIME CMD 7706 pts/0 00:00:00 bash 7845 pts/0 00:00:00 ps [jan@alpha-site Desktop]$ lsusb bash: lsusb: command not found [jan@alpha-site Desktop]$ ls -l /dev/hid* crw-rw---- 1 root root 180, 96 2008-05-04 05:34 /dev/hiddev0 crw-rw---- 1 root root 251, 0 2008-05-04 05:34 /dev/hidraw0 [jan@alpha-site Desktop]$ I took your change as meaning the line in the file hid.c and changed it too. After altering the file I clicked on hidtest and nothing seemed to happen. So then I did the above from the terminal. I can't find the process using ps -ef so I can't kill it and try over. after reboot hiddev is still open permission denied |
Try to run it as root. You don't have permissions to the device.
|
ktop]# hidtest
bash: hidtest: command not found [root@alpha-site Desktop]# ./hidtest usage: ./hidtest hiddevice - probably /dev/hiddev0 [root@alpha-site Desktop]# ./hidtest /dev/hiddev0 RadioShack Corporation USB Electronic Scale ready... Reading values .. exit The display just sat there at reading values, I put envelopes on and my glasses, and my finger, no changes. So I tried exit, then q, then escape, no effect. So I closed the terminal. Doubleclicking the hidtest icon as root didn't appear to do anything either. But it apparently does something as root! |
radioshack USB scale
I wrote some terribly sloppy code that seems to mostly work with the "Radio Shack USB Scale"
(ID 2233:6323 RadioShack Corporation USB Electronic Scale) Even though it's been a while since anyone posted this thread helped me initially and is the first result in google for "linux usb scale" The places where it is divided by 2.55 may be further fine-tuned by changing that number. If someone finds a better value please reply, as I don't have a comparison scale handy. That is, if it's possible to make sense of this ;) Code:
#include <stdlib.h> I know it's ugly! But at least give it a try with your RadioShack USB Scale if you're interested. |
Thanks! I'll go hunt down where it may have gone! I haven't had the time to fiddle with it. Wife's all mad because her XP got replaced with Linux and then her scale don't work, and the system is broke, when all she wants most is solitaire. Well...I put a few nice things on like a whole bunch of solitaire games and gnucash, and cosmos screensavers, and grandkid education stuff ... well she likes it better now than the xp! Except for the scale! I'll try it out and get back to you!
Really appreciate the effort! |
Actually after some more testing, under heavier weight this is broken... but it's a start.
|
Here it is able to work off of heavier weights.
Might still need some tuning for completely accurate weights, but it's fairly close. Code:
#include <stdlib.h> Rather than continue editing it here i'll keep the newest working at http://kubes.org/src/usbscale.c |
works with RadioShack scale on Ubuntu 11.10 64-bit
Thanks @bkubes. I downloaded the source from your website, built it, and it works on my 64-bit machine. Nice job.
Any plans to host this somewhere for others to fork and work from, ala GitHub? |
Thanks lucasrangit. While I love programming I'm still very much a novice..
A while back I found someone who had ported it to python- http://www.thok.org/intranet/python/usb/README.html He cleaned up the code some, and some of the variable names are more intuitive. I don't have any future plans for the code.. perhaps if I can find the scale again. However, if anyone wants to use / modify the source code they're free to do whatever they like. Best Regards |
All times are GMT -5. The time now is 08:03 PM. |