Hello World!

I am new to C and would like to write a C program to accomplish the following:

I have an external 600GB USB disk device, Padlock Pro. The device, which can be seeing at:
http://www.amazon.com/Apricorn-Encrypted-Portable-External-A25-PLe256-640/dp/B003EYVJTU/ref=sr_1_1?ie=UTF8&qid=1298479333&sr=8-1

has a number pad on it. It uses a maximum key of 16-digit, used to unlock the device.
If you plug the device to desktop the server does not know that it is connected until the user enters the security key. If you reboot, when the server comes up you need to reenter the key.

You might be asking by now what this has to do with C. Well, the potential problem with this device that I can see readily is the following. Once it is connected and recognized by the server, anyone with access to the server can also have access to the disk. I normally use the device connected to my laptop and so I rely on windows "security" keep the device from been accessed.

I would like to write a C program that:

  1. Periodically, say every 6 minutes, check for activities on that disk
  2. If the device has not been active during that period, 6 minutes, it should disconnect the device from the server

My questions are:

  1. How do I access, from a C program, a USB port
  2. Since the drive might change, how can I determine that I am on the correct device
  3. How can I check for activities on a USB without checking dor files updated, which can take a long time
  4. How do I disconnec the drive if no activity is detected.

I'm sorry for the length of this note and Thank you for your help!

TheCStudent

Recommended Answers

All 2 Replies

Well you need to a USB device driver for carrying out specific tasks. Though I am not an expert on drivers but I have below commetns on your question

1. How do I access, from a C program, a USB port
RP: You need to know which memory address range is mapped for USB devices, that you will come to know from your processor's data sheet. Processor's data sheet contians a range of memory address where all Tx and Rx data, USB registers are mapped. To perform any operation on USB device, you need to know these registers.

2. Since the drive might change, how can I determine that I am on the correct device
RP: Yes, it might happen. For this you need to know what is device id and make details of your USB drive. Again for such detail you must have data sheet of USB device.

3. How can I check for activities on a USB without checking dor files updated, which can take a long time
RP: Not much idea on this but I guess USB protocol might help on this. You can have some timer but question is how you will come to know that device is idle?

4. How do I disconnec the drive if no activity is detected.
RP: You need to check USB protocol, how to detach device from your PC. There must be some register on which if you write some command, that will taken as detach command by device.

Hope it gives you some thought...

Permalink, thank you for your reply. I'll look into your suggestions!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.