Reading USB data

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 !

Reply to
emil.nad
Loading thread data ...

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
Reply to
Tauno Voipio

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

formatting link

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.
Reply to
The Natural Philosopher

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.

Reply to
emil.nad

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

Reply to
Gordon Henderson

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.
Reply to
The Natural Philosopher

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.
Reply to
The Natural Philosopher

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
Reply to
Tauno Voipio

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/
Reply to
Richard Kettlewell

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.
Reply to
Dave Liquorice

Try lsusb -v or lsusb -vv

--

-Tauno
Reply to
Tauno Voipio

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 
spamtrap42@jacob21819.net 
(Yes, that is one of my email addresses.)
Reply to
Robert Riches

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.

Reply to
emil.nad

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

Reply to
Hils

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

--

-Tauno
Reply to
Tauno Voipio

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

Reply to
emil.nad

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.

formatting link

Reply to
emil.nad

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:

formatting link

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 
Web: http://www.satsignal.eu
Reply to
David Taylor

How about C# and mono. :*)

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

---druck

Reply to
druck

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.