Reading USB data

Do you have a question? Post it now! No Registration Necessary

Translate This Thread From English to

Threaded View
Hi.
I'm reading data from my PCB data logger and i send this data over usb/485
bus to raspberry PI. So far, so good. Now, does someone knows how to
write some application for PI and if this application can be java based.
C/C++ could also work.

Is it enough to write the app and install it to PI ? I never worked with
PI and i dont have HW test sample. I will get one in few days.

In general, im working on Linux so idea was to write this app and port it to PI.

Regards !

Re: Reading USB data
On 29.8.13 6:37 , snipped-for-privacy@gmail.com wrote:
Quoted text here. Click to load it


Forget Java. Its security features make file and I/O access difficult.

Create a C application which works on your desktop Linux, copy the  
sources over to Pi and compile there.

--  

Tauno Voipio


Re: Reading USB data
On 29/08/13 16:55, Tauno Voipio wrote:
Quoted text here. Click to load it
yes. with the proviso you should check that the way the Pi assigns  
device numbers to USB devices is the same.

I haven't accessed USB directly myself at the program level, but from  
reading about other peoples 'issues' don't assume the device will appear  
in the same way every time the pi is booted.

I *believe* and hopefully someone else knows a lot MORE - that the way  
of dealing with hot plug device events is changing or has changed and  
hasn't finished changing so the days when you opened /dev/ttysN are long  
gone.


This may be helpful

http://blog.mypapit.net/2008/05/how-to-use-usb-serial-port-converter-in-ubuntu.html

The good news is that whatever you proto on a linux desktop should work  
on the pi, as long as you have the same drivers available.

I'd definitely say use 'C' for work of this nature. Especially if you  
need a daemon.

--  
Ineptocracy

(in-ep-toc?-ra-cy) ? a system of government where the least capable to lead are elected by the least capable of producing, and where the members of society least likely to sustain themselves or succeed, are rewarded with goods and services paid for by the confiscated wealth of a diminishing number of producers.


Re: Reading USB data
On Thu, 29 Aug 2013 17:41:26 +0100, The Natural Philosopher wrote:

Quoted text here. Click to load it

On a linux PC there is no guarantee that a given linux device will be
assigned to the same physical port at anytime. Plug things in/out and
things *will* move around. The most recent device plugged in will get
the lowest available, relevant (tttyUSB, sd, etc) linux device,
irespective of the physical port into which it is plugged.

Looks like a Pi uses udev for device allocation. A few rules ought to
tie a given physical USB port to a linux device. From my server with
generic serial to USB convertors:

# For APC SmartUPS (Front USB Port 4 counting down from top)
KERNEL=="ttyUSB[0-9]*", ID=="4-2:1.0", SYMLINK+="apcups"

Means that whatever ttyUSB gets assigned to the physical port with ID
"4-2:1.0" it will also get the symlink "apcups". You then use the
symlink in your programs.  

Note this is on a system with several generic serial to USB
convertors connected, they don't have a unique serial number, hence
having to effectively assign a physical port for a given use. If you
have unique serial numbers you should be able to map that to a given
linux device/symlink and it won't matter which physical port it is
plugged into.

There is a useful command for getting port IDs, serial numbers, etc
but can't remember what it is. It's not lsusb, udevinfo?

--  
Cheers
Dave.




Re: Reading USB data
On 29.8.13 11:11 , Dave Liquorice wrote:
Quoted text here. Click to load it

Try lsusb -v or lsusb -vv

--  

-Tauno


Re: Reading USB data
Quoted text here. Click to load it

If you're using Java as a general-purpose programming language
rather than in a web browser, there's no more difficulty doing
file and other I/O than with C.  The ~25kloc of personal code on
which I registered copyright a few years ago did a lot of varied
text and binary file I/O, and Java security features never caused
even a tiny bit of difficulty.

--  
Robert Riches
snipped-for-privacy@jacob21819.net
We've slightly trimmed the long signature. Click to see the full one.
Re: Reading USB data
Hi guys.
I agree with you. C would be better solution.
OK. if there is no problem on porting and compiling the code on PI then, we have solve the situation.

What about compiler compatibility.  
I guess i can use the same compilers as in normal linux distro.

Re: Reading USB data
Quoted text here. Click to load it

Use Debian Wheezy and the only thin you'll notice is the speed...

I do a lot of development/editing, etc. on my Debian Wheezy desktop
then compile on the Pi - but sometimes I just do it on the Pi via ssh
and never notice...

Gordon

Re: Reading USB data
On 29/08/13 19:01, Gordon Henderson wrote:
Quoted text here. Click to load it
Or do it the  way I do on my remote VPS 'somewhereon the internet' NFS  
mount the machine, edit the files on the desktop, saving to the remote  
machine, and compile via ssh on the remote machine.

You can then be writing the next bit while the compiler chews through  
what you have already written.

--  
Ineptocracy

(in-ep-toc?-ra-cy) ? a system of government where the least capable to lead are elected by the least capable of producing, and where the members of society least likely to sustain themselves or succeed, are rewarded with goods and services paid for by the confiscated wealth of a diminishing number of producers.


Re: Reading USB data

Quoted text here. Click to load it

If you?re comparing wheezy proper with Raspbian you might notice that
the default compiler differs (4.6 in Raspbian, 4.7 in wheezy); I
certainly did.

Since both compilers exist in both operating systems this isn?t a big
deal, just a trivial nuisance the first time you notice it.

--  
http://www.greenend.org.uk/rjk/

Re: Reading USB data
On 29/08/13 18:54, snipped-for-privacy@gmail.com wrote:
Quoted text here. Click to load it
hard not to :-)


--  
Ineptocracy

(in-ep-toc?-ra-cy) ? a system of government where the least capable to lead are elected by the least capable of producing, and where the members of society least likely to sustain themselves or succeed, are rewarded with goods and services paid for by the confiscated wealth of a diminishing number of producers.


Re: Reading USB data
On 29.8.13 8:54 , snipped-for-privacy@gmail.com wrote:
Quoted text here. Click to load it

The Gnu C compiler on your desktop is very probably compatible with the  
Gnu C on the Pi.

I guess that your 'USB' is a RS485-to-USB dongle, which in the recent  
Linux distributions is seen as /dev/ttyUSBn, where 'n' is a digit. Just  
try opening and reading it, first in the desktop and then in Pi.

--  

Tauno Voipio



Re: Reading USB data
On 2013-08-29 19:48, Tauno Voipio wrote:
Quoted text here. Click to load it

I've used Python to read data from a logging multimeter on a USB port.
Python's serial data handling seems quite robust.

Re: Reading USB data
Little description of my project.
I have 485 lines connected to my 485 bus which will be connected to raspberry pi USB port (or 232 ). I send periodically 10KB data at 9600bps. On the PI sie, i have to read this data, reformat it and send it to web application.
----------------------------------------------
Possible problem
- in the future i will need to connect printer on raspberry but i dont know if this will work because there is just one USB connector. Other option is to use 485/232 adapter so i can leave USB port free.


@Robert
Can i use your code for such project and how much would it cost ?
If i find time i will start with C version but if i dont make it i would like to have backup solution.

Re: Reading USB data
On 30.8.13 1:27 , snipped-for-privacy@gmail.com wrote:
Quoted text here. Click to load it


Get a cheap powered USB hub. I just bought one for 7 connections for EUR 19.

--  

-Tauno


Re: Reading USB data
@Hils
Tell me more :-). Is there some sample source to download ?

Re: Reading USB data
One more thing.
What kind of raspberry PI model should i buy to make all this work.
I think i could take B model because am planning to put some additional apps on PI in the future. But if i take this model do i get all what i need or do i have to by some additional stuff ? Like power supply , sdcard etc.

http://www.element14.com/community/docs/DOC-51668?ICID=raspi-group

  

Re: Reading USB data
On 30/08/2013 15:55, snipped-for-privacy@gmail.com wrote:
Quoted text here. Click to load it

Personally,I find the Ethernet connection on the model-B handy, and the  
512 MB memory may be essential (depending on what you are doing).  You  
may need one or more of the following items, depending on your  
"scrap-box" contents:

  
https://www.modmypi.com/raspberry-pi-set-up-kits/basic-raspberry-pi-set-up-kit

SD card and power-supply are likely to be the minimum, plus perhaps a  
Wi-Fi adapter.  It depends on what you want to do....
--  
Cheers,
David
We've slightly trimmed the long signature. Click to see the full one.
Re: Reading USB data
On 29/08/2013 16:37, snipped-for-privacy@gmail.com wrote:
Quoted text here. Click to load it

How about C# and mono. :*)

Sorry, I really shouldn't say such things out loud.

---druck

Site Timeline