LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Hardware
User Name
Password
Linux - Hardware This forum is for Hardware issues.
Having trouble installing a piece of hardware? Want to know if that peripheral is compatible with Linux?

Notices


Reply
  Search this Thread
Old 03-17-2017, 11:33 PM   #1
swmcl
LQ Newbie
 
Registered: Mar 2017
Posts: 5

Rep: Reputation: Disabled
Defining the process when something is plugged into the USB port


Hi,

To preface everything ... I'm using a standard installation of Linux Mint 18.1.

I am building a little project. The hardware uses a chip that converts USB to serial at the front-end. So I believe what happens when the device plugs into the USB port is the following:

1. The kernel probes the port to inquire what the device is.
2. Hopefully the kernel will recognize my device as needing the cdc_acm 'module' or 'driver'.
3. My USB-to-serial chip uses a 12MHz crystal. I believe it is a USB 2.0 compatible chip.
4. As I understand it, the computer will communicate to the chip at USB 2.0 speeds.

I want to define a project where I pay someone to write me a program to detect changes on the USB port, see if the change on the USB ports is one of my chips, set the speed of the serial comms from the chip to the one required by the microprocessor on the other side and finally, query the microprocessor for an ID which is essentially registering the product.

So.

How am I going at defining the project?!

I don't know whether this is the sequence of events nor do I know what each part requires. For example, what does setserial do ? Is it the correct command to use to set the speed from my chip to my microprocessor ? I don't think so.

So my question is a top-level question seeking to understand the process and the terms or commands or programs I need to specify in the final solution.

Thanks in advance.

Steve
 
Old 03-18-2017, 07:15 AM   #2
michaelk
Moderator
 
Registered: Aug 2002
Posts: 25,694

Rep: Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894
Welcome to LinuxQuestions.

When inserted a USB device goes through an enumeration process where the computer identifies and loads a driver if recognized. This is all part of the USB subsystem and so writing a program is not required.

Depending on the make/model of USB chip you are using (like FTDI) it might have the USB protocol built which simplifies your design. In addition the computer driver is already written which eliminates driver development in most cases. If the USB chip is recognized as a virtual com port then your application program can use standard serial port protocols to set the speed and baud rate etc.

You can easily find the USB specification on the internet with a quick search but here is link that provides a simplified description.

http://www.ftdichip.com/Support/Docu...numeration.pdf
 
Old 03-18-2017, 07:33 AM   #3
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 21,125

Rep: Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120
If you want to know what happens when a USB device is plugged in run "udevadm monitor" from a terminal then plug your device in. Can be redirected to a file as normal.
dmesg will also be of interest.
 
Old 03-18-2017, 04:11 PM   #4
swmcl
LQ Newbie
 
Registered: Mar 2017
Posts: 5

Original Poster
Rep: Reputation: Disabled
Thanks for the replies.

The chip is not an FTDI but is a Microchip MCP2200. I did find a document that said it used the cdc_acm driver.

So, assuming the chip is recognized by the USB subsystem, how do I change the baud rate between it and the microprocessor? Can this be done from within a python program running in the background? If I were to do it manually, I have used the moserial program for a Silicon Labs 2102 on a different board and believe this would also be used in this case.

I am aware that lsusb -v for example might show me all the device attributes of the chip.

I'm actually in the middle of getting the thing built. I have the chip on my desk but the pcb is a little while away so I can't actually do 'it' at this time.

Thanks again for the help.
 
Old 03-18-2017, 04:38 PM   #5
michaelk
Moderator
 
Registered: Aug 2002
Posts: 25,694

Rep: Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894
Have you read the documentation?
http://www.microchip.com/wwwproducts/en/en546923

The device is programmed via the USB port using a Microchip configuration utility and once programmed the settings are stored in EEPROM. I assume it is a windows only program. In addition the vendor and product ID are also stored in EEPROM.
 
Old 03-18-2017, 07:35 PM   #6
swmcl
LQ Newbie
 
Registered: Mar 2017
Posts: 5

Original Poster
Rep: Reputation: Disabled
Aha!

Yes I did download the various files for the chip but I didn't quite make the links as to their purpose.

So. I must initially use the Windows Configuration Utility that probably isn't available on Linux (although Microchip are Linux-aware with MPLAB ...) to 'program' the MCP2200 baud rate to the microprocessor. I can also, I guess, get other information from the chip at this time for registration purposes - information not available in a Linux-environment that is ...

After the MCP2200 is setup wrt baud rate I can then run the device on Linux in a fairly transparent manner as the kernel will ID the chip and take it from there ...

OK!

Can't wait to try.

Thanks for you help.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
detection of a device when plugged through USB port chaitalil Linux - Newbie 6 02-12-2013 11:52 AM
setting up HP printer plugged into Belkin router USB port RayGo75 Linux - Newbie 14 01-16-2012 08:03 PM
Process crash while it reads write on the USB HDD and USB is plugged out. nitinarora Linux - Kernel 4 05-18-2009 03:37 AM
cable plugged into USB port produces errors wadesmart Linux - Hardware 2 01-28-2009 02:32 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Hardware

All times are GMT -5. The time now is 11:17 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration