EasyHid and 18F2550 - why? what? how?


Closed Thread
Results 1 to 1 of 1
  1. #1
    Join Date
    Aug 2005
    Posts
    27

    Default EasyHid and 18F2550 - why? what? how?

    Hi,

    I have a 18F2550 talking to windows with no apparent problems [see attached screendump].

    Easyhid generated the code, and I made what I believed to be the relevant changes [minor ones at first, in order to test all is well].

    Sure enough, if I connect the cable, the 'OnPlugged' event fires and the textbox changes to 'Plugged In..." [see code below].

    However, no matter what I do, I cannot get the 'hidRead' event to fire, nor does the 'OnUnplugged' event ever fire, when I disconnect the cable.

    I have scoured these forums and the 'net in general, and cannot see what I am missing...

    I've included the code snippets below. Any help would not only be much appreciated, but would save me from ritual hari-kari... ;-)

    Giulio

    ;------------------------------

    '************************************************* ****************
    ' a HID device has been plugged in...
    '************************************************* ****************
    Public Sub OnPlugged(ByVal pHandle As Long)
    If hidGetVendorID(pHandle) = VendorID And hidGetProductID(pHandle) = ProductID Then
    ' ** YOUR CODE HERE **

    Text1.Text = "Plugged In..."

    End If
    End Sub

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

    Text1.Text = "Unplugged..."

    End If
    End Sub


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

    ' read the data (don't forget, pass the whole array)...
    If hidRead(pHandle, BufferIn(0)) Then
    ' ** YOUR CODE HERE **

    Text1.Text = Val(BufferIn(0))

    ' first byte is the report ID, e.g. BufferIn(0)
    ' the other bytes are the data from the microcontrolller...
    End If
    End Sub

    ;-------------------------------------------------

    pic code
    ;---------

    DEFINE OSC 20

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

    ' the USB buffer...
    USBBuffer Var Byte[USBBufferSizeMax]
    USBBufferCount Var Byte

    ' ************************************************** **********
    ' * main program loop - remember, you must keep the USB *
    ' * connection alive with a call to USBService every couple *
    ' * of milliseconds or so... *
    ' ************************************************** **********

    usbinit
    ProgramStart:
    ' gosub DoUSBIn
    USBBuffer[0] = 79
    USBBuffer[1] = 75
    gosub DoUSBOut
    goto ProgramStart

    ' ************************************************** **********
    ' * receive data from the USB bus *
    ' ************************************************** **********
    DoUSBIn:
    USBBufferCount = USBBufferSizeRX ' RX buffer size
    USBService ' keep connection alive
    USBIn 1, USBBuffer, USBBufferCount, DoUSBIn ' read data, if available
    return

    ' ************************************************** **********
    ' * wait for USB interface to attach *
    ' ************************************************** **********
    DoUSBOut:
    USBBufferCount = USBBufferSizeTX ' TX buffer size
    USBService ' keep connection alive
    USBOut 1, USBBuffer, USBBufferCount, DoUSBOut ' if bus available, transmit data
    return
    Attached Images Attached Images  

Similar Threads

  1. Vusb capacitor for USB comms with 18f2550
    By rjones2102 in forum mel PIC BASIC Pro
    Replies: 12
    Last Post: - 25th September 2008, 00:15
  2. Problem to connect with 18F2550
    By Kacto in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 11th January 2008, 20:56
  3. EasyHID max usb buffer size
    By jizyjuice in forum USB
    Replies: 4
    Last Post: - 29th November 2007, 06:12
  4. 18f2550 'access is denied' USB error?
    By Giulio in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 30th December 2006, 15:29
  5. HIDMakerFS versus EasyHID
    By Demon in forum USB
    Replies: 4
    Last Post: - 15th August 2006, 09:01

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