So first of all, an apology in advance, English is not my main language.
I was testing the USB demos and I realized that for someone who is starting it would be a bit difficult and frustrating the part of installing the drivers, due to the fact that these drivers are not signed; for people who are more seasoned there will be no problem when testing them, but even for any useful project, a more viable solution will be required.
So, I took the task of creating an installer that would take care of circumventing these problems, the installer unzips the files in C:\drivers\, puts the operating system in disable driver signature enforcement mode, installs the drivers, reverts to normal mode and delete the contents of C:\drivers.
The two main disadvantages are the following: requires (automatically) restart the computer 2 times to change modes. And also requires that the computer does not have secure boot enabled to be fully autonomous. In case secure boot is enabled, the installer automatically detects it, and will restart the computer in boot selection mode to choose the driver signature enforcement mode manually and continue with the driver installation (I know that this way is convoluted but I have not found another way in case of having secure boot enabled and not having drivers signed by Microsoft).
In the zip file I add the compiled exe and all the source code to build it. the main installer (which only takes care of unzipping the files and adding a key to the windows registry) is done in Install Creator Pro 2, It is a freeware available here https://www.clickteam.com/download-centre/install-creator-pro-2
the other two applications inside (one is responsible for detecting if the secure boot is present on the computer and determining the best way to change mode and restart the computer, and the other is responsible for installing the driver, reverting the mode and deleting the content from the folder) both are console applications written in C#. uses .Net Framework 3.0 (I purposely chose it to run easily on legacy OS) If you are going to play with those assemblies remember that they are programmed to restart the computer without asking, so be careful.
the drivers as they were in the demo does not work for windows 11, so I made they work now.
I personally tried that it worked (both installer and drivers) in:
Windows 11 pro x64 secureboot disabled, os build Dev 21H2 22000.194
Windows 11 pro x64 secureboot enabled, os build Dev rs_prerelease 22458.1000
Windows 10 pro x64 secureboot disabled, os build stable 20H2 19042.867
Windows 7 pro x86 secureboot disabled, os service pack 1 build 6.1.7601
in those environments runs perfect.
I am aware that the code can be improved (my goal was to make it work) I hope I do not receive too much heat :) think that it was only a day's work; feel free to modify it, use it, or add it to the demos or whatever you want. I hope that it would be useful to someone.
Hi, I can’t open the OneDrive link, it says that it doesn’t exist, it expired or I don’t have permissions to access it.
In regards of the help page; did you mean the steeps to how to install it?
I’m glad to do it.
I know that it will be a good idea to add images of what to select when windows restart in WinRE (windows recovery environment), I think it will be the most awkward for the ones that have secure boot enabled.
I suppose that you will need it in the “Great-Cow-BASIC-Help/source/” repo in .adoc format, that’s right?
What file name you need for it?
Best regards.
Angel
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi Evan, I already do another little project for the USB part that I think it will be of interest for your project. I see that the pic programming is very easy thanks to the USB.h library. But the vb.net part may be a little confusing to someone’s because one needs to understand all the code in the example and needs something like 500 lines of code for a just simple program.
I have the idea to make one library for vb.net and C# of the GCB USB functions, but I want only one DLL, I don’t want to import LibUsbDotNet.dll + Another.dll and make a mess.
I looked for the git repo of the LibUsbDotNet project, cloned it and revert it to version 2.2.9.110, a little bit a head of the old release (actual work in the repo is mainly trying to convert it to .Net Core and still doesn’t work) that release solved some minor bugs and its fully functional.
After that I started cleaning up the project to get rid of all the unneeded code and parts for an easy future mod. Then I make another name space inside the dll called GCBlib and started to translate your demo code to C# (because LibUsbDotNet is written in C# and I only want one dll) I just do some little code optimization of your actual code, added overloads to the functions for easy use, added a function to send and array to the PIC, etc.
At the end I have a little dll called GCBlib.dll of only 146kb whit a class named USBlib that facilitates programming of the usb part.
Whit this a simple hello world program can be like this:
ImportsGCBlibPublicClassForm1DimUSBAsNewUSBlibPrivateSubForm1_Load(senderAsObject, eAsEventArgs)HandlesMyBase.Load'Initialize USB daemon from startUSB.InitializeUSB()EndSubPrivateSubTimerDeviceConnection_Tick(senderAsObject, eAsEventArgs)HandlesTimerDeviceConnection.Tick'Get the device connection statusIfUSB.GetConnectedStatus=TrueThenLabel1.Text="Device Connected"ElseLabel1.Text="Device not Connected"EndIfEndSubPrivateSubHelloButton_Click(senderAsObject, eAsEventArgs)HandlesHelloButton.Click'Send a simple command whitouth dataUSB.SendData(100)EndSubEndClass
The timer of your code is embedded on the class and runs internally, the final programmer doesn’t need to interact whit that, in the zip file I uploaded here, I added a full demo whit every one of the functions of the USBlib class, even whit this dll if you are an advanced programmer you can access the LibUsbDotNet name space and classes.
Whit this project in the future will be easier to add new functionality to the USB part, I would like to se if there is a chance to send a command from the PIC to the PC and catch it in an event handler on the dll, I think it will be useful.
In the ZIP:
“USB Test” folder is the demo project whit all functions covered (User Solution)
“GCBlib” folder is the full library project (GCBlib and LibUsbDotNet) when you open the project, look for the USBlib.cs object inside of the GCBlib directory.
USB demo 45k50.gcb is the test program used whit “USB Test”
If you are interested, just tell me to add it to a repo and start making the help page for it.
'USB Demo for the GCBlib USB LibraryImportsGCBlibPublicClassForm1DimUSBAsNewUSBlibPrivateSubForm1_Load(senderAsObject, eAsEventArgs)HandlesMyBase.Load'Initialize USB daemon from startUSB.InitializeUSB()EndSubPrivateSubTimerDeviceConnection_Tick(senderAsObject, eAsEventArgs)HandlesTimerDeviceConnection.Tick'Get the device connection statusIfUSB.GetConnectedStatus=TrueThenLabel1.Text="Device Connected"ElseLabel1.Text="Device not Connected"EndIf'Show if the USB daemon is runningDaemonStatusRadioButton.Checked=USB.InitializedEndSubPrivateSubHelloButton_Click(senderAsObject, eAsEventArgs)HandlesHelloButton.Click'Send a simple command whitouth dataUSB.SendData(100)EndSubPrivateSubLCDlightCheckBox_CheckedChanged(senderAsObject, eAsEventArgs)HandlesLCDlightCheckBox.CheckedChanged'Send a command and data as BitUSB.SendData(102, LCDlightCheckBox.Checked)EndSubPrivateSubByteTrackBar_Scroll(senderAsObject, eAsEventArgs)HandlesByteTrackBar.Scroll'Send a command and data as ByteByteLabel.Text=ByteTrackBar.ValueUSB.SendData(103, ByteTrackBar.Value)EndSubPrivateSubSendArrayButton_Click(senderAsObject, eAsEventArgs)HandlesSendArrayButton.Click'Send a command and a data arrayDimdata(2)AsBytedata(0)=100data(1)=255data(2)=22USB.SendData(104, data)EndSubPrivateSubGetStatusButton_Click(senderAsObject, eAsEventArgs)HandlesGetStatusButton.Click'Poll and read 1 Byte from the devicePORTaLabel.Text=USB.ReadData(101)EndSubPrivateSubGetArrayButton_Click(senderAsObject, eAsEventArgs)HandlesGetArrayButton.Click'Poll and read a data arrayDimdata()AsBytedata=USB.ReadData(105, 3)IfdataIsNothingThenMsgBox("No data received...")ElseMsgBox("Data Received: "&data(0)&","&data(1)&","&data(2))EndIfEndSubPrivateSubStartButton_Click(senderAsObject, eAsEventArgs)HandlesStartButton.Click'Initialize USB daemonUSB.InitializeUSB()EndSubPrivateSubTerminateUSBButton_Click(senderAsObject, eAsEventArgs)HandlesTerminateUSBButton.Click'Terminate USB daemonUSB.TerminateUSB()EndSubEndClass
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
So first of all, an apology in advance, English is not my main language.
I was testing the USB demos and I realized that for someone who is starting it would be a bit difficult and frustrating the part of installing the drivers, due to the fact that these drivers are not signed; for people who are more seasoned there will be no problem when testing them, but even for any useful project, a more viable solution will be required.
So, I took the task of creating an installer that would take care of circumventing these problems, the installer unzips the files in C:\drivers\, puts the operating system in disable driver signature enforcement mode, installs the drivers, reverts to normal mode and delete the contents of C:\drivers.
The two main disadvantages are the following: requires (automatically) restart the computer 2 times to change modes. And also requires that the computer does not have secure boot enabled to be fully autonomous. In case secure boot is enabled, the installer automatically detects it, and will restart the computer in boot selection mode to choose the driver signature enforcement mode manually and continue with the driver installation (I know that this way is convoluted but I have not found another way in case of having secure boot enabled and not having drivers signed by Microsoft).
In the zip file I add the compiled exe and all the source code to build it. the main installer (which only takes care of unzipping the files and adding a key to the windows registry) is done in Install Creator Pro 2, It is a freeware available here https://www.clickteam.com/download-centre/install-creator-pro-2
the other two applications inside (one is responsible for detecting if the secure boot is present on the computer and determining the best way to change mode and restart the computer, and the other is responsible for installing the driver, reverting the mode and deleting the content from the folder) both are console applications written in C#. uses .Net Framework 3.0 (I purposely chose it to run easily on legacy OS) If you are going to play with those assemblies remember that they are programmed to restart the computer without asking, so be careful.
the drivers as they were in the demo does not work for windows 11, so I made they work now.
I personally tried that it worked (both installer and drivers) in:
Windows 11 pro x64 secureboot disabled, os build Dev 21H2 22000.194
Windows 11 pro x64 secureboot enabled, os build Dev rs_prerelease 22458.1000
Windows 10 pro x64 secureboot disabled, os build stable 20H2 19042.867
Windows 7 pro x86 secureboot disabled, os service pack 1 build 6.1.7601
in those environments runs perfect.
I am aware that the code can be improved (my goal was to make it work) I hope I do not receive too much heat :) think that it was only a day's work; feel free to modify it, use it, or add it to the demos or whatever you want. I hope that it would be useful to someone.
So it was a long day. greetings to all.
Angel.
A great piece of work.
Can I recommend we move to GitHub then this will get installed when a complete installation of Great Cow BASIC is created.
We should replace https://github.com/Anobium/Great-Cow-BASIC-Demonstration-Sources/tree/master/USB_Solutions/GreatCowBASIC_Solutions/LIBWINUSB_Solutions/WindowsDeviceDriver
To upload to GitHub take a fork, add your code, and then merge.
I would also add the SHA and MD5 hashes alongside the installer. This will prove it has not been tampered with.
:-)
@Angel Change #1027 see https://onedrive.live.com/Edit.aspx?resid=2F87FFE77F3DBEC7!67634&wd=cpe&authkey=!ADmkT3exl5l4Pkc
Question: Should we add a page in the Help to show how to use the driver? This information will be lost if we leave in this post. :-(
Hi, I can’t open the OneDrive link, it says that it doesn’t exist, it expired or I don’t have permissions to access it.
In regards of the help page; did you mean the steeps to how to install it?
I’m glad to do it.
I know that it will be a good idea to add images of what to select when windows restart in WinRE (windows recovery environment), I think it will be the most awkward for the ones that have secure boot enabled.
I suppose that you will need it in the “Great-Cow-BASIC-Help/source/” repo in .adoc format, that’s right?
What file name you need for it?
Best regards.
Angel
Any ASCII file will do. To convert to ADOC will take a few seconds. So, if you write, I can change to ADOC.
Hi, pull request ready in the Great-Cow-BASIC-Help repo, added help page and image.
Greetings
Angel
Thank you for your hard work. https://github.com/Anobium/Great-Cow-BASIC-Help/blob/master/source/USBdriversInstaller.adoc
I have just integrated into all the formats!
See http://gcbasic.sourceforge.net/help/ in a few hours as this take a while to upload.
See http://gcbasic.sourceforge.net/help/_usb_drivers_installer.html
Last edit: Anobium 2021-09-25
Hi Evan, I already do another little project for the USB part that I think it will be of interest for your project. I see that the pic programming is very easy thanks to the USB.h library. But the vb.net part may be a little confusing to someone’s because one needs to understand all the code in the example and needs something like 500 lines of code for a just simple program.
I have the idea to make one library for vb.net and C# of the GCB USB functions, but I want only one DLL, I don’t want to import LibUsbDotNet.dll + Another.dll and make a mess.
I looked for the git repo of the LibUsbDotNet project, cloned it and revert it to version 2.2.9.110, a little bit a head of the old release (actual work in the repo is mainly trying to convert it to .Net Core and still doesn’t work) that release solved some minor bugs and its fully functional.
After that I started cleaning up the project to get rid of all the unneeded code and parts for an easy future mod. Then I make another name space inside the dll called GCBlib and started to translate your demo code to C# (because LibUsbDotNet is written in C# and I only want one dll) I just do some little code optimization of your actual code, added overloads to the functions for easy use, added a function to send and array to the PIC, etc.
At the end I have a little dll called GCBlib.dll of only 146kb whit a class named USBlib that facilitates programming of the usb part.
Whit this a simple hello world program can be like this:
The timer of your code is embedded on the class and runs internally, the final programmer doesn’t need to interact whit that, in the zip file I uploaded here, I added a full demo whit every one of the functions of the USBlib class, even whit this dll if you are an advanced programmer you can access the LibUsbDotNet name space and classes.
Whit this project in the future will be easier to add new functionality to the USB part, I would like to se if there is a chance to send a command from the PIC to the PC and catch it in an event handler on the dll, I think it will be useful.
In the ZIP:
“USB Test” folder is the demo project whit all functions covered (User Solution)
“GCBlib” folder is the full library project (GCBlib and LibUsbDotNet) when you open the project, look for the USBlib.cs object inside of the GCBlib directory.
USB demo 45k50.gcb is the test program used whit “USB Test”
If you are interested, just tell me to add it to a repo and start making the help page for it.
Greetings
Angel
I forget to mention that:
Code for all examples of the class:
Got some screen shots? :-) Very good to see the USB in use.