USB CDC.

General discussion on mikroPascal.
Author
Message
Dany
Posts: 3854
Joined: 18 Jun 2008 11:43
Location: Nieuwpoort, Belgium
Contact:

#31 Post by Dany » 01 Nov 2008 18:18

fabim wrote:Dany hello, I came back.
Danny, in his library in the function.
CopyDescriptorToEP0.
You use a variable type pointer,
const DescriptorPointer: ^ byte; / / pointer to constant memory <<.
I do not understand how you are using this pointer, you could you explain that, I think the error is there.
Hi Fabim,
this is a pointer to constant memory (where the fixed USB descriptor tables are). Before "CopyDescriptorToEP0" is called "DescriptorPointer" gets the startaddress of a descriptortable, e.g.

Code: Select all

      DescriptorPointer          := @DeviceDescriptor;
and the rest (sending the descriptortable to the USB host) is then done by calls to "CopyDescriptorToEP0". :D
Kind regards, Dany.
Forget your perfect offering. There is a crack in everything, that's how the light gets in... (L. Cohen)
Remember when we were young? We shone like the sun. (David Gilmour)

Dany
Posts: 3854
Joined: 18 Jun 2008 11:43
Location: Nieuwpoort, Belgium
Contact:

#32 Post by Dany » 01 Nov 2008 18:25

Dany wrote:
Tomy wrote:I send you two files, it is ping pong buffer info. Hope it help.
Because your email address have problem, I PM you. Please check.
Hi Tomy, thanks very much, that will be a great help! :D
Hi, no success with ping-pong buffering yet. First I tried mode 3 (all endpoints use ping pong buffering except endpoint zero), but I discovered (after a long time testing and trying) this mode does not work on all PIC versions (on "older" versions mode 3 is said to be "unsupported").

So, I was obliged to go back to mode 2 (ALL endpoints, including zero, do use ping pong buffering). The net result is now that the enumeration process is going horribly wrong, from in the beginning of it.

I will keep you informed... :cry:
Last edited by Dany on 29 Nov 2008 11:16, edited 1 time in total.
Kind regards, Dany.
Forget your perfect offering. There is a crack in everything, that's how the light gets in... (L. Cohen)
Remember when we were young? We shone like the sun. (David Gilmour)

Tomy
Posts: 47
Joined: 25 Jun 2007 16:50

#33 Post by Tomy » 04 Nov 2008 12:24

Dany,

Thank you for your hard work :P

Zsola
Posts: 16
Joined: 29 Nov 2008 02:31

Polling?

#34 Post by Zsola » 29 Nov 2008 02:49

Hello!
I have a question:
Is there possible to make such one-way communication (from PIC to PC) at certain, unknown delayed times when you can receive data? Or we can use only polling?
One example to make it clear: I want to send data only after a button pushed on PIC. I don't want to "ask" the PIC wheter the button pushed or not. That consume USB bandwith and resources (don't laugh). The doing on PIC are clear, I want to optimize the software on PC.
On a couple of Delphi components - thats don't work with the PICs as you mentioned on your webpage - there is an "OnDataAvailable" or "OnDataReceived" event, so it tells in the SW I have to read or not.
I tried CiaComport, nrComm and ZylCom port components, neither worked. What do you mean on "such behavior", what kind of settings we shall make (DTR, Xon-off, etc.)?

Thank you very much!
Keep up the good work ;)

Dany
Posts: 3854
Joined: 18 Jun 2008 11:43
Location: Nieuwpoort, Belgium
Contact:

Re: Polling?

#35 Post by Dany » 29 Nov 2008 11:32

Zsola wrote:Is there possible to make such one-way communication (from PIC to PC) at certain, unknown delayed times when you can receive data? Or we can use only polling?
One example to make it clear: I want to send data only after a button pushed on PIC. I don't want to "ask" the PIC wheter the button pushed or not. That consume USB bandwith and resources (don't laugh). The doing on PIC are clear, I want to optimize the software on PC.
On a couple of Delphi components - thats don't work with the PICs as you mentioned on your webpage - there is an "OnDataAvailable" or "OnDataReceived" event, so it tells in the SW I have to read or not.
I tried CiaComport, nrComm and ZylCom port components, neither worked. What do you mean on "such behavior", what kind of settings we shall make (DTR, Xon-off, etc.)?
Hi, the only thing I know is that on the PC side the communication has to be done with ReadFile and WriteFile calls to an open com port when using the usbcom driver (see the PC software deivered with the CDC library). I do not know what type of calls the software you mention use.
Also "Hyperterminal" does not work. :cry: With the PC software I delivered is a delphi file "Wincon.pas", wherein you can find all SW to open/close/read/write a com port. :D

About usb "polling": the PC itself does always polling to all the usb devices. No device can signal to the PC it has something unless it is polled by the PC. Of course, in high level software constructions like with "OnDataAvailable" can be present, but nevertheless, the PC always polls the USB devices on "usb level". :cry:

p.s. All "line" settings of a com port like this (a virtual one) have no meaning (at least not with the usbcom driver): DTR, CTS, Xon, Xof, baudrate, etc...). The only things that are important are the "ComTimeouts" (defined in Wincom.pas) for the (virtual) comport.
Kind regards, Dany.
Forget your perfect offering. There is a crack in everything, that's how the light gets in... (L. Cohen)
Remember when we were young? We shone like the sun. (David Gilmour)

Dany
Posts: 3854
Joined: 18 Jun 2008 11:43
Location: Nieuwpoort, Belgium
Contact:

#36 Post by Dany » 29 Nov 2008 11:39

Hi all, an USB CDC library with buffer ping pong mode (mode 2) is also available now:
http://www.mikroe.com/forum/viewtopic.p ... 1&start=37 :D
Kind regards, Dany.
Forget your perfect offering. There is a crack in everything, that's how the light gets in... (L. Cohen)
Remember when we were young? We shone like the sun. (David Gilmour)

Zsola
Posts: 16
Joined: 29 Nov 2008 02:31

#37 Post by Zsola » 29 Nov 2008 12:58

Hi Dany,
That was quick :D
The OnDataAvailable event means that the component can check is data received (to PC), and fires a procedure - so you don't have to read at certain interval, the data gets to you when it is available.
Thank you very much, You are the BEST! :)

Post Reply

Return to “mikroPascal General”