EasyHID and USB for Newbies??


Closed Thread
Results 1 to 40 of 69

Hybrid View

  1. #1
    Join Date
    Aug 2005
    Posts
    42

    Default

    Using easyhid is not that bad.

    Basic steps are run up the easyhid program and set the basics like Pid/Vid and buffer size for bytes you want to send back and forth from PC to Pic.

    It then by default creates two folders under a top level folder called USBProject

    The first folder is PICBasicPRO

    This contains the basic code you will need for your pic chip and the include files, do not rename or move this directory once it is created, work from this location.
    It will create a example PBP file called USBProject.pbp

    So open this up and the main program loop you are interested in is:


    '****************************************
    usbinit ' initialise USB...

    ProgramStart:

    gosub DoUSBIn
    gosub DoUSBOut

    goto ProgramStart
    '*****************************************

    For receving and sending data you just need these two routines.

    If you wanted to receive say 10 bytes then it does matter that your buffer is set to 64 bytes because that is the packet size that is going to be received from the PC anyway, so do not worry about this. Just tell it to jump off to that routine and as soon as data is received it will come back from that routine with the usbbuffer(0) to usbbuffer(63) filled as such.
    So if your PC sent 10 bytes then the variables usbbuffer(0-9) will hold those 10 bytes, if your pc sent 20 bytes then usbbuffer(0-19) will hold those bytes.

    So say you wanted to send 4bytes from your PC to the Pic and then the Pic displays it on the LCD, you could do this:

    '*******************************************
    usbinit ' initialise USB...
    ProgramStart:

    gosub DoUSBIn

    LCDOUT $FE,1,usbbuffer(0),usbbuffer(1),usbbuffer(2),usbbu ffer(3)

    goto ProgramStart
    '*******************************************

    If you then wanted to send say two bytes back to the PC to say you received them, then just load up your usbbuffer variables and jump to the routine gosub DoUSBOut.

    So to send "OK" back to the PC add this to your code.

    '*******************************************
    usbinit ' initialise USB...
    ProgramStart:

    gosub DoUSBIn

    LCDOUT $FE,1,usbbuffer(0),usbbuffer(1),usbbuffer(2),usbbu ffer(3)

    usbbuffer(0)=79 'Ascii value for O
    usbbuffer(1)=75 'Ascii value for K
    gosub DoUSBOut

    goto ProgramStart
    '*******************************************

    And thats ya simple pic code to receive and send bytes back and forth. Now you know how to get your bytes in and out, you can use them just like any other variables.

    The Second Folder it creates is dependent on what you are developing in, I play with Visual Basic so it created me a Folder called VisualBasic and inside here is sample code and the files you will need, I aslo copy the file mcHID.dll from C:\Program Files\Mecanique\EasyHID\ into this folder as well to play safe.

    So again for the VB side of things to send data out to the Pic via the USB Port you simply load up the Bufferout(1-64) you always send Bufferout(0)=0 as a header.

    So to send 4 bytes from Visual Basic just use the following:

    '*******************************************

    BufferOut(0) = 0
    BufferOut(1) = 68 'Ascii Value for D
    BufferOut(2) = 65 'Ascii Value for A
    BufferOut(3) = 84 'Ascii Value for T
    BufferOut(4) = 65 'Ascii Value for A
    hidWriteEx VendorID, ProductID, BufferOut(0)

    '*******************************************

    To receive Data in VB, the sample code basically sits there and waits for a recieve event to happen and when it does, it jumps off to a routine called OnRead and populates the variables BufferIn(1-64).

    So you could do a simple loop to keep checking the value of BufferIn(1) and BufferIn(2) until they receive the "OK\2 back.
    To see it in action set up a object called Text1.Text on your VB Form and then in your code add the following:
    '*******************************************

    Text1.Text = Chr(Val(BufferIn(1)))
    Text1.Text = Text9.Text & Chr(Val(BufferIn(2)))

    '*******************************************

    Hope this helps.

    Regards Sean.
    Last edited by sean-h; - 6th February 2006 at 19:54.
    *********************
    http://www.cncdudez.co.uk
    *********************

  2. #2
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    3,170

    Default

    Thanks Sean, but like I posted back on Jan 10th that's not quite it. There's gotta be more required on the PC side. That code just doesn't sit in a text file, it has to be compiled or something. That's where all the USB threads come up short. Either everyone is assuming a whole bunch about what we 'should' know, or I'm too dense and just not getting something obvious...

    Robert
    My Creality Ender 3 S1 Plus is a giant paperweight that can't even be used as a boat anchor, cause I'd be fined for polluting our waterways with electronic devices.

    Not as dumb as yesterday, but stupider than tomorrow!

  3. #3
    Join Date
    Aug 2005
    Posts
    42

    Default

    Hi Robert

    When you say more PC side, yep you are correct, you will need a copy of Visual Basic for the code example above and at least know the basics of creating a windows application.

    There are a number of different development packages out there for writing your own windows applications, such as Visual Basic, Delphi, Visual C++ or the newer .NET .

    The sample code created by easy HID is for the first 3 development platforms listed bove.

    So first you need to get a development package, then you need to learn how to use it. Visual Basic to me has always been the easiest, have played with Delphi a little.

    When you have your development package you can then start learning how to write your own applications, and there are literaly thousands of development websites where other guys have already came across any problems that you will encounter and also would of posted sample code to help you out.

    Regards

    Sean.

    Quote Originally Posted by Demon
    Thanks Sean, but like I posted back on Jan 10th that's not quite it. There's gotta be more required on the PC side. That code just doesn't sit in a text file, it has to be compiled or something. That's where all the USB threads come up short. Either everyone is assuming a whole bunch about what we 'should' know, or I'm too dense and just not getting something obvious...

    Robert
    Last edited by Demon; - 4th October 2016 at 16:39.
    *********************
    http://www.cncdudez.co.uk
    *********************

  4. #4
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    3,170

    Default

    Thanks Sean, that explains it more.

    I'm also very interested in VB, I have VB Express installed already. What's the big difference between Visual Basic Express and uh, the 'regular' version?

    I keep seeing that .NET mentionned, but I have no idea what that implies. I don't want my application to be dependant on having .NET installed on a PC. I'm interested in a basic 'keyboard' type application that can be connected to a PC with minimal requirements.

    Is VB Express the proper tool for me?

    Robert
    My Creality Ender 3 S1 Plus is a giant paperweight that can't even be used as a boat anchor, cause I'd be fined for polluting our waterways with electronic devices.

    Not as dumb as yesterday, but stupider than tomorrow!

  5. #5
    Join Date
    Aug 2005
    Posts
    42

    Default

    Visual Basic Express is the cutdown version of VB.net or Visual basic 2005 as it is now called, I even struggle to keep up with the latest versions must admit, good old Mircosoft!!

    VB5 and VB6 have been very popular and used alot over the years, but as life moves on, like any other develpment tools they get upgraded to suit the latest operating systems.

    I have tried to migrate a few of my applications to Visual basic 2005 from VB6 but it falls over on a few bits of code and so personaly I stick to VB6 for now, but no dought I will have to find time and force myself to look at VB2005 in more depth one day.

    I have no idea what they have taken out of VB Express 2005 compared to what is in the full version.
    You are best to check the Microsoft site.

    Years ago VB6 came in several flavours and the low end version release did not include the Comm components, so for example you could not write applications that used the serial port, without either upgrading or getting the extra components from somewhere else.

    I know the sample code that gets produced with EasyHid is for VB5 but it works fine in VB6. It did not work in Visual Basic 2005 for me when trying to do a quick conversion, but I am sure with a bit of time and tweaking it hopefully will.

    Regards

    Sean.
    *********************
    http://www.cncdudez.co.uk
    *********************

  6. #6
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    3,170

    Default

    Hmm, HIDmaker came in today. I checked through the user's manual and it says the code is made for VB6.

    So now I'm not really sure what I should do: risk that what I will develop will work on VBexpress, or buy VB6 (investing in something else that is already obsolete, which may very well be dropped by HIDmaker soon).

    VBexpress was free...

    Robert
    My Creality Ender 3 S1 Plus is a giant paperweight that can't even be used as a boat anchor, cause I'd be fined for polluting our waterways with electronic devices.

    Not as dumb as yesterday, but stupider than tomorrow!

  7. #7
    Join Date
    Oct 2005
    Posts
    28

    Default

    VB.net or whatever you want to call it is no doubt the next generation, but VB6 is still around and is very robust.I do quite a bit of work with it and I find it has very few shortcomings for what I do. Programs compile and run seamlessly on all versions of Windows from 98 to XP pro, NT and 2000, Have not tried it on 64 bit Windows as of yet.

    If you can get VB6 for a reasonable price I wouldn't hesitate to get started with it. Make sure you patch it with the latest service pack (6).

  8. #8
    Join Date
    Aug 2005
    Location
    Los angeles
    Posts
    39

    Default

    Quote Originally Posted by sean-h
    Using easyhid is not that bad.

    Basic steps are run up the easyhid program and set the basics like Pid/Vid and buffer size for bytes you want to send back and forth from PC to Pic.

    It then by default creates two folders under a top level folder called USBProject

    The first folder is PICBasicPRO

    This contains the basic code you will need for your pic chip and the include files, do not rename or move this directory once it is created, work from this location.
    It will create a example PBP file called USBProject.pbp

    So open this up and the main program loop you are interested in is:


    '****************************************
    usbinit ' initialise USB...

    ProgramStart:

    gosub DoUSBIn
    gosub DoUSBOut

    goto ProgramStart
    '*****************************************

    For receving and sending data you just need these two routines.

    If you wanted to receive say 10 bytes then it does matter that your buffer is set to 64 bytes because that is the packet size that is going to be received from the PC anyway, so do not worry about this. Just tell it to jump off to that routine and as soon as data is received it will come back from that routine with the usbbuffer(0) to usbbuffer(63) filled as such.
    So if your PC sent 10 bytes then the variables usbbuffer(0-9) will hold those 10 bytes, if your pc sent 20 bytes then usbbuffer(0-19) will hold those bytes.

    So say you wanted to send 4bytes from your PC to the Pic and then the Pic displays it on the LCD, you could do this:

    '*******************************************
    usbinit ' initialise USB...
    ProgramStart:

    gosub DoUSBIn

    LCDOUT $FE,1,usbbuffer(0),usbbuffer(1),usbbuffer(2),usbbu ffer(3)

    goto ProgramStart
    '*******************************************

    If you then wanted to send say two bytes back to the PC to say you received them, then just load up your usbbuffer variables and jump to the routine gosub DoUSBOut.

    So to send "OK" back to the PC add this to your code.

    '*******************************************
    usbinit ' initialise USB...
    ProgramStart:

    gosub DoUSBIn

    LCDOUT $FE,1,usbbuffer(0),usbbuffer(1),usbbuffer(2),usbbu ffer(3)

    usbbuffer(0)=79 'Ascii value for O
    usbbuffer(1)=75 'Ascii value for K
    gosub DoUSBOut

    goto ProgramStart
    '*******************************************

    And thats ya simple pic code to receive and send bytes back and forth. Now you know how to get your bytes in and out, you can use them just like any other variables.

    The Second Folder it creates is dependent on what you are developing in, I play with Visual Basic so it created me a Folder called VisualBasic and inside here is sample code and the files you will need, I aslo copy the file mcHID.dll from C:\Program Files\Mecanique\EasyHID\ into this folder as well to play safe.

    So again for the VB side of things to send data out to the Pic via the USB Port you simply load up the Bufferout(1-64) you always send Bufferout(0)=0 as a header.

    So to send 4 bytes from Visual Basic just use the following:

    '*******************************************

    BufferOut(0) = 0
    BufferOut(1) = 68 'Ascii Value for D
    BufferOut(2) = 65 'Ascii Value for A
    BufferOut(3) = 84 'Ascii Value for T
    BufferOut(4) = 65 'Ascii Value for A
    hidWriteEx VendorID, ProductID, BufferOut(0)

    '*******************************************

    To receive Data in VB, the sample code basically sits there and waits for a recieve event to happen and when it does, it jumps off to a routine called OnRead and populates the variables BufferIn(1-64).

    So you could do a simple loop to keep checking the value of BufferIn(1) and BufferIn(2) until they receive the "OK\2 back.
    To see it in action set up a object called Text1.Text on your VB Form and then in your code add the following:
    '*******************************************

    Text1.Text = Chr(Val(BufferIn(1)))
    Text1.Text = Text9.Text & Chr(Val(BufferIn(2)))

    '*******************************************

    Hope this helps.

    Regards Sean.


    Hi Sean,

    If i want to write a byte to the microncontroller can i say BufferOut(2)=%10011111 (" for example)
    In your code above:
    BufferOut(1) = 68 'Ascii Value for D
    BufferOut(2) = 65 'Ascii Value for A
    BufferOut(3) = 84 'Ascii Value for T
    BufferOut(4) = 65 'Ascii Value for A
    hidWriteEx VendorID, ProductID, BufferOut(0)
    and to send the info,
    are you sending BufferOut(2), BufferOut(3)....and so on?
    if i wanna send the values in bufferout(2) would the code look like this below?
    hidWriteEx(VendorID, ProductID, BufferOut(0),BufferOut(2) )


    Thanks much
    Last edited by rocky79; - 21st February 2006 at 03:55.

  9. #9
    Join Date
    Aug 2005
    Posts
    42

    Default

    Hi rocky

    When you call hidWriteEx(VendorID, ProductID, BufferOut(0)), what you are doing is sending a packet as such out to the USB port.
    So you can define the length of that buffer in your VB vode at the top of the code:
    Private Const BufferInSize = 64
    Private Const BufferOutSize = 64

    and in your PBP code:

    USBBufferSizeMax con 64 ' maximum buffer size
    USBBufferSizeTX con 64 ' input
    USBBufferSizeRX con 64 ' output

    I think min is 8 bytes and max 64.

    So just change these variables to cut down the amount of bytes you want to send.

    BufferOut(0) is a report ID and data starts at BufferOut(1)

    Regards

    Sean.




    Quote Originally Posted by rocky79
    Hi Sean,

    If i want to write a byte to the microncontroller can i say BufferOut(2)=%10011111 (" for example)
    In your code above:
    BufferOut(1) = 68 'Ascii Value for D
    BufferOut(2) = 65 'Ascii Value for A
    BufferOut(3) = 84 'Ascii Value for T
    BufferOut(4) = 65 'Ascii Value for A
    hidWriteEx VendorID, ProductID, BufferOut(0)
    and to send the info,
    are you sending BufferOut(2), BufferOut(3)....and so on?
    if i wanna send the values in bufferout(2) would the code look like this below?
    hidWriteEx(VendorID, ProductID, BufferOut(0),BufferOut(2) )


    Thanks much
    *********************
    http://www.cncdudez.co.uk
    *********************

  10. #10
    Join Date
    Aug 2005
    Location
    Los angeles
    Posts
    39

    Default

    Thanks Sean for the explanation, but there is still something i don't understand.
    Question#1:
    On the microcontroller side: How can i send the results of a 12 bits A2d Signal from the microcontroller to visual basic.net since USBBufferout is defined as a byte.
    Question#2
    on the Visual basic.net side when your ready to send data back to the controller:
    do you just include all the 64 bufferout bufferout(1) bufferout(2)....bufferout(63)
    HidWriteEx, VendorId, ProductID, BufferOut(0), BufferOut(1)....BufferOut(63)
    Or is there a shorter way to do it.

    Thanks Sean

  11. #11
    Join Date
    Aug 2005
    Location
    Los angeles
    Posts
    39

    Default One more question

    Question#2:
    On the visual studio.net side: In this code below that i got from EasyHid how do you fill in where it says: put your code here?
    I would appreciate Any examples:

    Public Sub OnPlugged(ByVal pHandle As Integer)
    If hidGetVendorID(pHandle) = VendorID And hidGetProductID(pHandle) = ProductID Then
    ' ** YOUR CODE HERE **
    End If
    End Sub

    '************************************************* ****************
    ' a HID device has been unplugged...
    '************************************************* ****************
    Public Sub OnUnplugged(ByVal pHandle As Integer)
    If hidGetVendorID(pHandle) = VendorID And hidGetProductID(pHandle) = ProductID Then
    ' ** YOUR CODE HERE **
    End If
    End Sub

    '************************************************* ****************
    ' controller changed notification - called
    ' after ALL HID devices are plugged or unplugged
    '************************************************* ****************
    Public Sub OnChanged()
    Dim DeviceHandle As Integer

    ' get the handle of the device we are interested in, then set
    ' its read notify flag to true - this ensures you get a read
    ' notification message when there is some data to read...
    DeviceHandle = hidGetHandle(VendorID, ProductID)
    hidSetReadNotify(DeviceHandle, True)
    End Sub

    '************************************************* ****************
    ' on read event...
    '************************************************* ****************
    Public Sub OnRead(ByVal pHandle As Integer)

    ' read the data (don't forget, pass the whole array)...
    If hidRead(pHandle, BufferIn(0)) Then
    ' ** YOUR CODE HERE **
    ' first byte is the report ID, e.g. BufferIn(0)
    ' the other bytes are the data from the microcontrolller...
    End If
    End Sub

    '************************************************* ****************
    ' this is how you write some data...
    '************************************************* ****************
    Public Sub WriteSomeData()
    BufferOut(0) = 0 ' first byte is always the report ID
    BufferOut(1) = 10 ' first data item, etc etc

    ' write the data (don't forget, pass the whole array)...
    hidWriteEx(VendorID, ProductID, BufferOut(0))
    End Sub
    End Class

  12. #12
    Join Date
    Aug 2005
    Posts
    42

    Default

    Hi Rocky

    I got compile errors in VB2005 so sticking with VB6, does it compile okay with ,net your end?

    The two main routines to worry about and get you going are receive and transmit Data Routines.

    Please scroll up on this post as I have given some VB examples already on what you have just asked.

    Regards

    Sean.
    *********************
    http://www.cncdudez.co.uk
    *********************

  13. #13
    Join Date
    Aug 2005
    Location
    Los angeles
    Posts
    39

    Default

    sean,
    Sorry for the late reply, my computer crashed so i was crippled for the past week. I will try your code as soon as i get things back in place.
    thank you much

  14. #14
    Join Date
    Aug 2005
    Location
    Los angeles
    Posts
    39

    Default

    Quote Originally Posted by sean-h
    Hi Rocky

    I got compile errors in VB2005 so sticking with VB6, does it compile okay with ,net your end?

    The two main routines to worry about and get you going are receive and transmit Data Routines.

    Please scroll up on this post as I have given some VB examples already on what you have just asked.

    Regards

    Sean.
    Sean,
    I am just wondering if you know any good graphical widgets for Visual basic 6.0. Like meters, gauges, level indicators and so forth.

    Thanks

  15. #15
    Join Date
    Aug 2005
    Posts
    42

    Default

    Quote Originally Posted by rocky79
    Thanks Sean for the explanation, but there is still something i don't understand.
    Question#1:
    On the microcontroller side: How can i send the results of a 12 bits A2d Signal from the microcontroller to visual basic.net since USBBufferout is defined as a byte.
    A byte is only 8 bits so you will have to store your result in a variable defined as a Word (16bits)
    Now you will need to split the word and send the highbyte and lowbyte out as two bytes.
    In your VB program you will then need to take the 2 bytes and joing them back as a word.

    Quote Originally Posted by rocky79
    Question#2
    on the Visual basic.net side when your ready to send data back to the controller:
    do you just include all the 64 bufferout bufferout(1) bufferout(2)....bufferout(63)
    HidWriteEx, VendorId, ProductID, BufferOut(0), BufferOut(1)....BufferOut(63)
    Or is there a shorter way to do it.
    Re-read what I wrote above regards data being sent from VB. when you call HidWriteEx, VendorId, ProductID, BufferOut(0) you are telling the USB port to send all the data in the BufferOut.
    So if you have defined your BufferOut as being 64 bytes long then when you call HidWriteEx it will send all 64 bytes, if you defined your BufferOut as being 8bytes long then it will send 8 bytes.

    So simply load all the buffers up with the bytes you want and call HidWriteEx when you want to send.

    Regards

    Sean.
    *********************
    http://www.cncdudez.co.uk
    *********************

  16. #16
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    3,170

    Default

    Quote Originally Posted by sean-h
    Hi rocky
    ...
    USBBufferSizeMax con 64 ' maximum buffer size
    USBBufferSizeTX con 64 ' input
    USBBufferSizeRX con 64 ' output

    I think min is 8 bytes and max 64.
    ...
    Sean.
    Nope, 1 to 64 bytes for both input and output buffers according to EasyHID help files under Configuration Details.

    Robert
    My Creality Ender 3 S1 Plus is a giant paperweight that can't even be used as a boat anchor, cause I'd be fined for polluting our waterways with electronic devices.

    Not as dumb as yesterday, but stupider than tomorrow!

  17. #17
    bigbear's Avatar
    bigbear Guest

    Default

    Is there somewhere that I can see a list of the assembly codes for a PIC such as the 18F4550? From what I understand there are not a huge list of them. It has been a while since I did assembler, but I would like to have the ability to combine PBP and assembler.

  18. #18
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    3,170

    Default

    You'll have better luck getting an answer to an Assembler-related question if you start a new thread in the General forum:
    http://www.picbasic.co.uk/forum/forumdisplay.php?f=7

    This thread is about EasyHID and interfacing via USB.

    Robert
    My Creality Ender 3 S1 Plus is a giant paperweight that can't even be used as a boat anchor, cause I'd be fined for polluting our waterways with electronic devices.

    Not as dumb as yesterday, but stupider than tomorrow!

  19. #19
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898

    Default

    Quote Originally Posted by bigbear
    Is there somewhere that I can see a list of the assembly codes for a PIC such as the 18F4550? From what I understand there are not a huge list of them. It has been a while since I did assembler, but I would like to have the ability to combine PBP and assembler.
    you can mix both of them using ASM and ENDASM. You can have the asm list if you open the .COD file or the .LST file
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  20. #20
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    3,170

    Default

    Ok, I've reread this thread hoping to find a hint why the device is not recognized by windows.

    I had it working using HIDMaker FS, but I'm trying to use EasyHID since the resulting code is MUCH more compact. Here's what I've done so far:

    - generated code with EasyHID, 1 byte to PC, 30 bytes to PIC.
    - modified generated PBP program to include an LCD, that works great.
    - move MCHID.dll to VB6 working folder.
    - compiled the generated VB code using VB6.
    - started up the executable.
    - reset the PIC and that's when the error appears in Windows.

    Can the generated VB6 code work without doing any input or output? I was trying to just get a skeleton VB6 program working first, and then add 1 feature at a time.

    Robert
    Last edited by Demon; - 17th August 2006 at 00:12.
    My Creality Ender 3 S1 Plus is a giant paperweight that can't even be used as a boat anchor, cause I'd be fined for polluting our waterways with electronic devices.

    Not as dumb as yesterday, but stupider than tomorrow!

  21. #21
    Join Date
    Aug 2005
    Posts
    42

    Default

    Hi Rocky

    Sorry forgot to answer this bit

    Quote Originally Posted by rocky79
    If i want to write a byte to the microncontroller can i say BufferOut(2)=%10011111 (" for example)
    In VB you will need to convert your Binary value to Decimal and then load your Bufferout(2) variable.

    Here is a nice feunction example for Visual Basic

    http://www.vb-helper.com/howto_decimal_to_binary.html

    Regards

    Sean.
    *********************
    http://www.cncdudez.co.uk
    *********************

  22. #22
    lentz's Avatar
    lentz Guest

    Default

    Hi, my name is Davide. i'm start to program the pic18f4550.
    This topic is very interesting!!

    Usually i program pic16c765 and i use VB6 and the HIDcomm component for comunicate by USB with my pic.
    Now, my question is: Have you got a simple example for turn on a led with pic18f4550 by vb6?

    Thank for your time.

    Regard, Davide

  23. #23
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    3,170

    Default

    Quote Originally Posted by sean-h
    Using easyhid is not that bad.

    ...

    If you wanted to receive say 10 bytes ... Just tell it to jump off to that routine and as soon as data is received it will come back from that routine with the usbbuffer(0) to usbbuffer(63) filled as such.
    So if your PC sent 10 bytes then the variables usbbuffer(0-9) will hold those 10 bytes, if your pc sent 20 bytes then usbbuffer(0-19) will hold those bytes.

    ...

    Hope this helps.

    Regards Sean.

    (yup, I saw the correction in another post about byte 0 containing the endpoint and the data being in bytes 1 to 10.)


    So if I understand this properly, we don't have to worry about any of the USB registers when we receive data. I assume this is all done by the generated assembler code?

    The important thing is for us to know the exact length of our transferred data and that's it. We don't need any interrupt either, the USBIN command will execute until all the bytes are received (returning to the label DoUSBIn until complete).

    That leaves one thing, how do we handle an error? Are we to assume everything will always work? Are there flags provided by the assembler routines? Or are we supposed to use the USB error registors described in the PIC datasheet?

    Robert
    My Creality Ender 3 S1 Plus is a giant paperweight that can't even be used as a boat anchor, cause I'd be fined for polluting our waterways with electronic devices.

    Not as dumb as yesterday, but stupider than tomorrow!

Similar Threads

  1. Simple USB Comms Problem
    By awmt102 in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 6th January 2010, 20:17
  2. EasyHID max usb buffer size
    By jizyjuice in forum USB
    Replies: 4
    Last Post: - 29th November 2007, 05:12
  3. Speed of USB EasyHID and Time problem
    By sjohansson in forum USB
    Replies: 10
    Last Post: - 18th January 2007, 22:21
  4. USB and EasyHID Problems
    By Rob in forum USB
    Replies: 8
    Last Post: - 6th January 2007, 18:19
  5. USB PIC without USB Connection
    By Tissy in forum mel PIC BASIC Pro
    Replies: 9
    Last Post: - 26th December 2005, 17:39

Members who have read this thread : 1

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts