Hi
I am trying to write a file to a USB device using C program..
When i try to open the USB port, i find the foll error
"open_port: unable to open usbdev2.1_ep81: No such file or directory"
The command to open the USB port: -
sprintf(portfile,"/dev/usbdev2.1_ep81");
-
if((fd=open(portfile, O_RDWR | O_NOCTTY | O_NDELAY))==-1)
-
perror("open_port: unable to open usbdev2.1_ep81");
-
Please provide some inputs/help
Thanks,
Priya
18 4384
Please read your PM's, accessible via the link in the top right corner of the page.
You are trying to access the device from /dev/, which means you have not mounted it. In Linux the device needs to be mounted before it can be accessed. What flavor (distribution) are you running? I know Debian will automount and put it in /media/usbdisk/ so you might try looking around your / or /mnt directory for a 'media' or 'usb' folder.
Please read your PM's, accessible via the link in the top right corner of the page.
You are trying to access the device from /dev/, which means you have not mounted it. In Linux the device needs to be mounted before it can be accessed. What flavor (distribution) are you running? I know Debian will automount and put it in /media/usbdisk/ so you might try looking around your / or /mnt directory for a 'media' or 'usb' folder.
Hi
I am using Debian flavor.
What i m trying to do is use a C program to access USB device in the same way as the COM port are accessed in Serial Communication.
Thanks
Hi
I am using Debian flavor.
What i m trying to do is use a C program to access USB device in the same way as the COM port are accessed in Serial Communication.
Thanks
Just because it is a different device will mean that you will not be able to access it the same way you would access a serial communication. I mean, it's possible to write wrappers and everything to create that functionality, but you will need to access it differently, just because it is a USB device and not a serial device.
What version of Debian? Did you check the /media folder?
Devices need to be mounted before you can access them as directories and files. Take a look at the mount command (i.e. man mount) and google for "usb mount" for more details.
Many times linux will automatically mount devices for you at bootup and when they get plugged in. Take a look in your desktop for an icon and take a look in the root directory for /mnt and/or /media. The devices are mounted under these directories. Once you find the mounting directory use it like any other path. (i.e. /mnt/usb1/blah/blah/blah)
Just because it is a different device will mean that you will not be able to access it the same way you would access a serial communication. I mean, it's possible to write wrappers and everything to create that functionality, but you will need to access it differently, just because it is a USB device and not a serial device.
What version of Debian? Did you check the /media folder?
Following is the system details
Linux debianTSP 2.6.18-4-686 #1
Also i checked the media folder so it shows me the usbdisk dir created over there.
I want to access any of the following using C program
debianTSP:/media/usbdisk# ls -lart /dev/u*
crw-rw-rw- 1 root root 442, 0 2007-08-31 12:24 /dev/usbdev1.1_ep00
crw-rw---- 1 root root 442, 0 2007-08-31 12:24 /dev/usbdev1.1_ep81
crw-rw---- 1 root root 442, 1 2007-08-31 12:24 /dev/usbdev1.2_ep00
crw-rw---- 1 root root 442, 1 2007-08-31 12:24 /dev/usbdev1.2_ep81
Following is the system details
Linux debianTSP 2.6.18-4-686 #1
Also i checked the media folder so it shows me the usbdisk dir created over there.
I want to access any of the following using C program
debianTSP:/media/usbdisk# ls -lart /dev/u*
crw-rw-rw- 1 root root 442, 0 2007-08-31 12:24 /dev/usbdev1.1_ep00
crw-rw---- 1 root root 442, 0 2007-08-31 12:24 /dev/usbdev1.1_ep81
crw-rw---- 1 root root 442, 1 2007-08-31 12:24 /dev/usbdev1.2_ep00
crw-rw---- 1 root root 442, 1 2007-08-31 12:24 /dev/usbdev1.2_ep81
Ok, do me a favor and do
man ls
by specifying /dev/u* you are listing the contents of the /dev/ directory that start with u, doesn't matter if you're in /media/usbdisk/ or not because you are using the absolute path (starting with / ). "man" will allow you to look at how a command should be implemented - it's short for "manual". You can do that for almost any command.
Then try this:
cd /media/usbdisk/
ls -alh
That will show you the modules in /media/usbdisk. And you can then use those as RRick has said - use the path to them as you would any other path.
Thanks for the same.
Well i looked in /media/usbdisk/, it shows me the boot directory..
Also i m using a putty to access the machine :-(
Tried with the mount command..gave an error
mount /dev/usbdev1.1_ep00
mount: can't find /dev/usbdev1.1_ep00 in /etc/fstab or /etc/mtab
Tried with the mount command..gave an error
mount /dev/usbdev1.1_ep00
mount: can't find /dev/usbdev1.1_ep00 in /etc/fstab or /etc/mtab
What was the output of the 'ls' command in /media/usbdisk/ ?
Let's make sure it is not already mounted first...
Just4priya,
You're actually pretty close to getting something to work.
First, stay away from the /dev directory (unless you really know what you're doing). Its not going to work the way you expect it to work. Usually, devices (things in /dev) are mounted (by the mount command) to a file system (directories and files).
If you can access /media/usbdisk, then its already been mounted (maybe). Go to that directory and start looking for directories and files like Sicarie told you. Putty will work fine in this case. The normal files commands (i.e. ls, mkdir, cd) should work here. Try creating a file by copying one over or use the touch command. If these work, then your C program will be able to do the same.
Hi
The output of ls command is
ls -l /media/usbdisk/
boot/ .created_by_pmount
I don't have permissions to create a file /media/usbdisk/ :-(
Thanks
Hi
The output of ls command is
ls -l /media/usbdisk/
boot/ .created_by_pmount
I don't have permissions to create a file /media/usbdisk/ :-(
Thanks
You shouldn't have to create anything - it should be there already. I'm not sure your usb drive is mounted there. What's supposed to be on it? (ie - is there supposed to be a 'boot' directory as the root of the USB filesystem?)
You shouldn't have to create anything - it should be there already. I'm not sure your usb drive is mounted there. What's supposed to be on it? (ie - is there supposed to be a 'boot' directory as the root of the USB filesystem?)
I could see a boot directory available in /media/usbdisk/
I could see a boot directory available in /media/usbdisk/
Right, but is that a directory that is supposed to be on your USB disk?
Around and around and around we go. Its difficult to know for certain whether the usb drive is mounted or not. Is the boot directory correct or not?
There is one way to find out, but it takes a couple of system reboots.
Unplug all the USB drives, and then reboot. Good back to /media and look for the usbdrive and boot directories. If one or both disappear, then they probably belong to the removed drive(s).
Shutdown the computer, add one (1) usb drive, and bootup. Go back to /media and look again. Is anything added? If so, then there's your drive.
If nothing changes during all of this, then these directories do not connect to your usbdrive.
Around and around and around we go. Its difficult to know for certain whether the usb drive is mounted or not. Is the boot directory correct or not?
There is one way to find out, but it takes a couple of system reboots.
Unplug all the USB drives, and then reboot. Good back to /media and look for the usbdrive and boot directories. If one or both disappear, then they probably belong to the removed drive(s).
Shutdown the computer, add one (1) usb drive, and bootup. Go back to /media and look again. Is anything added? If so, then there's your drive.
If nothing changes during all of this, then these directories do not connect to your usbdrive.
Yeah, the OP is connecting via Putty, so I was going on "they don't have physical access".
You can also use the command 'df' to show mounted drives. Something should point to something with "usb" in the name...
Hi,
I was successfully able to mount the USB disk and write a file into it.
Thanks for all the help provided
Priya
Good for you. Mounting is not a trivial task for unix boxes.
Some unixes try to protect the user from "mount" and sometimes they succeed and sometimes they don't.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Jim Hubbard |
last post by:
It seems that Microsoft not only does not need the classic Visual Basic
developer army (the largest army of developers the world has ever seen), but
now they don't need ANY Windows developer at a...
|
by: Clément |
last post by:
Hello, i'm new to c++ and to linux, i have to develop a full web browser.
I don't really know how to start and i'd like to know if any of you would
have some kind of
working plan/structure in...
|
by: mr.iali |
last post by:
Hi Everyone
I would like to get into software developent using a programming
language like c++, java or pl/sql for oracle.
I have no idea where to start from. Which language is there more...
|
by: Mathias Goldau |
last post by:
Hi,
Can someone tell me where I find some material (e.g. a compiler with
graphics.h and conio.h (for free)) related to graphic programming BGI-like,
and sound programming (not PC-speaker). The...
|
by: João Pires |
last post by:
I have a program write in VB and I need to convert the code to C for Linux.
Well, I began to do that but I have some problems ...
- How can I write te code in C to comunicate with the serial...
|
by: Martin |
last post by:
Hello,
We are in the process of putting together an A class PHP Development
team(ecommerce / billing applications) for a project in the Bay Area.
Reqt. details:
ReqId : Req-3616 - Senior PHP...
|
by: john |
last post by:
To test a new piece of software designed to help with (among other
things) eCommerce WWW site development. The software is fairly easy to
use but you must fit a profile. Retail price is 120 GBP and...
|
by: Nirjhar Oberoi |
last post by:
Hi,
I am new to Linux and wanted to know how to use GCC to Compile the Code
written in C? I dont want to use EMacs or VI for my editor. Can you
suggest a good IDE for linux for C Programming..
...
|
by: leeanngriego |
last post by:
I have a client who has asked me to find him some solid up and coming
embedded engineers. 2 to 3 years expereince with Embedded Linux,
VxWorks, Nucleus or any other RTOS who has working in L2/L3...
|
by: Amar |
last post by:
I am a system programmer , doing my program in C/RedHat LINUX ES4.0
version. I want to do concurrent programming in C , which will utilise
my system's 4 processor simutaneously.
I need some one's...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
| |