Can libusb be build using GNU GCC compiler? - c++

I am trying to start using libusb for communication via COM port ( EDIT: for my Rs232 device), on windows 10 x64 only. My IDE is Code:blocks. I have a couple of questions:
I downloaded libusb from their website (latest windows binaries)
But I noticed there is a libusb-win32 ''version'' of it in sourceforge. It says
"libusb-win32 is a port of libusb-0.1 under Windows"
What does this mean, and should I use the "latest windows binaries" version or the "libusb-win32" version?
Also, the Readme file from their website (the 'libusb windows binaries' one) has instructions for compiling in Visual Studio and Mingw and there are files for Visual studio and Mingw only.
Does this means I cannot compile the libusb it in GNU GCC compiler?
EDIT: the question 2) is already answered here: https://stackoverflow.com/a/38252750/13294095

"I am trying to start using libusb for communication via COM port ( EDIT: for my Rs232 device), on windows 10 x64 only"
If you have a device that when you plug it into your PC via a USB port, it instantiates a COM port, then that device does have a UART. The device must also have driver that upon connecting to the PC is installed, and results in establishing the serial port you can see in device manager (under ports) Read about USB serial driver for some background.
"I have a physical uart device after the Rs232, I my MCU. I use the Rs-232 to translate from UART to USB protocol. -Even though I do not
know what "Virtual com port" is."
Your device may have a UART, but when you plug it into a PC via a USB port, a virtual serial port is created via a driver on the PC... "When the USB to serial adapter is connected to the computer via the USB port the driver on the computer creates a virtual COM port which shows up in Device Manager on Windows"... Read more here. (under Architecture)
In short, if when you plug your device into the PC, you can see a port that has been created in Device Manager, then all the work is done. Your application code can incorporate a C serial port library to open a port and send/receive serial messages, etc. However, if you are developing the device with the UART to work on a Windows PC via a USB port, then yes, you need to create a driver. Maybe then libUSB is for you.

Related

Problem developing "Windows C / C ++ desktop application" to connect Windows10 to a bluetooth 5.0 device

I'm building a Windows Desktop application in C/C++ VS2017 for BLE5.0.
If I pair the bluetooth of my Windows computer through the control panel, my application is able to receive/send bluetooth messages.
My problem is to establish a connection without making the association from the control panel.
Do you know if there are any Windows functions/messages that allow me to scan for bluetooth devices and then make a connection?
Thank's a lot
Bye

How to detect if /dev/ttyGS0 is connected or not

I am writing a c++ program on my linux device where I can connect the device's micro usb to my computers (host) USB port. I want my program to detect if /dev/ttyGS0 has a device connected to it or not and if it does, I want my device to connect to it right away without having to send any data from my computer. And if it disconnects, I want it to also detect that and close the port. I do not want to use libusb for this. I want to use a different library.
As of now, I am using the fcntl.h library. I'm open to any other libraries and suggestions.

c++ dll via Win runtime component in c# UWP app works for Arm but not for x86/x64

I need to call win32 socket apis from C# UWP app for Windows10(same app to run on desktop and mobile) as win10 sock library has some issues
Environment - VS2015 Update 3.
I created project structure as explaind here.
So the calling is as follows..
C# UWP app -> C++ WindowsRuntimeComponent -> Universal dll(c++) (having code from c++ win32 dll)
In dll I simply create a UDP server and wait for udp packets at recvfrom(.....)
This works fine when I run the app on Win 10 Mobile device (ARM) but does not work when architecture selected is x86 or x64. I donot recive any udp packet forx64/x86 in recvfrom() while bind() is successful.
How is it that same code works for ARM and not for x64/x86. What could be the issue.
Windows Store applications cannot listen on sockets or receive data from UDP connections if both ends of the socket are on the same machine. Run the server and your application on separate machines.
A security patch was waiting to install on the clinet machine (Win 7 OS) was the reason for server waiting in recvfrom() call...
After the patch was installed and system restarted, it worked fine.
Faced with the same problem. The recvfrom function has not received packets from the local network. The problem was resolved by adding the privateNetworkClientServer capability to the application manifest (https://learn.microsoft.com/en-us/windows/uwp/packaging/app-capability-declarations).

Serial communication over RS232 and USB

I plan to write serial driver to send data from target to host. The target is a renasas RX62N. And the host is windows 8.1. The target has RS232 port and the host has a USB port. I plan to use a converter cable with DB9(not sure) and USB connectors. 1) would like to know if I can send and receive from target and host? 2) would like to know if there is a way of getting around writing USB driver to send and receive from host is there software(Program) that could monitor usb port and send and receive dats over USB port? Ive seen software that let you send data and see the data receive by a port.
(1) RS-232 is bidirectional. You can send and receive at the same time.
(2) You do not have to write a USB driver for the host. Windows has this built in. Use the standard Windows serial I/O calls. They work the same way for serial ports and for USB to serial converters.
The USB<->RS-232 converter cable will appear to the PC host as a legacy serial port, support for the CDC/ACM USB profile that implements this port emulation is built into Windows, Linux and OSX. In windows however you will normally have to install "driver" which in most cases will simply be a INF file that maps the cable's USB vendor/product ID to the usbser.sys devive driver. Some USB/Serial devices may have custom drivers.
Common USB CDC/ACM devices from FTDI and Prolific will install drivers automatically via Windows Update (though historically Prolific drivers have been problematic - though recently they have improved).
At the target end, you communicate via the UART that is wired to the RS-232 line driver as you would normally.
For basic testing and keyboard/screen console access to your target, you van use any terminal emulator software such as TeraTerm, HyperTerminal, or Putty.

What usb device is connected to a usb port

I'll try to keep this simple.
I have a hub connected to my PC. This hub has several USB interfaces. I'm listening to WM_DEVICECHANGE event and I get the USB interface path. How can I know what port it was connected to? Looking for a non-WMI solution in c++ or c# for a windows environment.
I tried using IOCTL_USB_GET_NODE_CONNECTION_NAME with USB_NODE_CONNECTION_NAME (where USB_NODE_CONNECTION_NAME.NodeName will hold the path to the device) but this only works if the device connected to the port is a hub as well.
Any help will be much appreciated.
The primary issue in C++ is that there is no standard functions for detecting USB ports.
USB Port identification and implementation is a platform specific issue. For example, Linux handles USB ports quite differently than Windows and many embedded systems don't have USB ports.
So you'll have to look for a 3rd party library or find some OS API to use for your platform.