Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

How to send String text from USB_HID P18F4550 to PC

Status
Not open for further replies.

Dauwed

Newbie level 2
Joined
Aug 25, 2018
Messages
2
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Activity points
19
Hello everyone
I am going to design a project using C# application. and I want to use USB_HID PIC18F4550 as a dongle license for my C# application.
For more details, I need to send string word from USB_HID to my PC and then read it by C# application. This string word I will use it as Key a license for my application.
Please, can someone help me?
Thanks in advance
 
Last edited:

Have you set the VID and PID properly ? Zip and post your complete VC#.Net and mikroC PRO PIC project files with Proteus file if any. What USB HID component are you using to communicate with VC#.Net application ?

Try this code.


Code C - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
unsigned char readbuff[64] absolute 0x500;   // Buffers should be in USB RAM, please consult datasheet
unsigned char writebuff[64] absolute 0x540;
//---------------------------------------------------------------------------------------------------
void interrupt()
{
   USB_Interrupt_Proc();                   // USB servicing is done inside the interrupt
}
 
int i = 0;
char key[] = "abcd";
 
void main(void)
{
 //-----------------------------------------------variable area--------------------------------------
 trisb=0; // port as output
 portb=0xff;
 trisc=0;
 ADCON1 |= 0x0F;                         // Configure all ports with analog function as digital
 CMCON  |= 7;
 
 HID_Enable(readbuff,writebuff);      // Enable HID communication
  
 while(1) {
  
    strcpy(writebuff, key);
    while(!(HID_Write(writebuff,64));
 }   
}



If you just send key as say string abcd or defg then anybody can capture USB data and find out the key. So, you have to encrypt your key say adcd to say ntpq and send it to VC# app and in VC# app you have to decrypt the ntpq key back to abcd and then check if key is adcd and if it is then you have to unlock features in your VC# app. This is for simple dongle. Try to use minimum 64 characters for the key.

- - - Updated - - -

Do you want something like the attached.
 

Attachments

  • USB HID Communication.rar
    315.3 KB · Views: 57
  • SS1.png
    SS1.png
    320.3 KB · Views: 73
Last edited:

I asked you which USB HID component (.dll file) are you using to communicate with VC#.net application. I also asked you to post your VC#.Net project if any.

Also dongle needs to be small and compact. If the only purpose of the dongle is for licensing of the software then why do you want to use the bigger PIC18F4550 ? Why can't you use PIC18F2550 ?

- - - Updated - - -

The code of the C# depends upon which USB HID component (.dll) you are using for USB HID communication. We need to know this to provide you C# code or guide you.

Some of the USB HID components are

mcHID.dll
USBHIDNetCalss.dll

I think mcHID.dll only works with VB.Net.

USBHIDNetClass.dll works with VB.Net and VC#.Net and you need a license to use it. There is a demo version of it for downloading but it pops up a demo message once every few minutes.
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top