Recent Posts

Pages: 1 [2] 3 4 ... 10
11
USB / Re: Should Feature Units define nothing for channels without controls?
« Last post by jb on August 02, 2021, 10:45:41 am »
Yes, but both of the above examples are using a single control, with Ch1 and Ch2 controls undefined.  I'm just not sure if I have to specify 0x00 for them or can leave them out entirely.

"The bmaControls() array is an array of bit-maps, each indicating the availability of certain audio Controls
for a specific logical channel or for the master channel 0. For future expandability, the number of bytes
occupied by each element (n) of the bmaControls() array is indicated in the bControlSize field. The
number of logical channels in the cluster is denoted by ch."

"bmaControls() is a (ch+1)-element array of 4-byte bitmaps, each containing a set of bit pairs. "

"bmaControls() is a (ch+1)-element array of 4-byte bitmaps, each following the same semantics as the bmControls
field in other descriptors."

So I guess it always has to be of length ch+1 and the unused channels should be blank 0x00?
13
Serial Ports / VBA Winsock
« Last post by nector on July 30, 2021, 06:14:54 am »
I'm having some challenges to have the VBA/Winsock code work in my Ms Access application. The VBA code appear not responding , see if you have a solution to this:

Code: [Select]
Option Compare Database

Option Explicit


Public Const COMMAND_ERROR = -1
Public Const RECV_ERROR = -1
Public Const NO_ERROR = 0
Public socketId As Long
'Global Variables for WINSOCK
Global State As Integer

Sub CloseConnection()
Dim x As Long
' we close our connection here
    x = closesocket(socketId)
    If x = SOCKET_ERROR Then
        MsgBox ("ERROR: closesocket = " + Str$(x))
        Exit Sub
    End If
End Sub

Sub EndIt()
Dim x As Long
    'Shutdown Winsock DLL
    x = WSACleanup()
End Sub


Function OpenSocket(ByVal Hostname As String, ByVal PortNumber As Integer) As Integer
   
    Dim I_SocketAddress As sockaddr_in
    Dim ipAddress As Long
    Dim x As Long
   
    ipAddress = inet_addr(Hostname)

    'Create a new socket
    socketId = socket(AF_INET, SOCK_STREAM, 0)
    If socketId = SOCKET_ERROR Then
        MsgBox ("ERROR: socket = " + Str$(socketId))
        OpenSocket = COMMAND_ERROR
        Exit Function
    End If

    'Open a connection to a server
    I_SocketAddress.sin_family = AF_INET
    I_SocketAddress.sin_port = htons(PortNumber)
    I_SocketAddress.sin_addr = ipAddress
    I_SocketAddress.sin_zero = String$(8, 0)

    x = connect(socketId, I_SocketAddress, Len(I_SocketAddress))
    If socketId = SOCKET_ERROR Then
        MsgBox ("ERROR: connect = " + Str$(x))
        OpenSocket = COMMAND_ERROR
        Exit Function
    End If
    OpenSocket = socketId
End Function

Function SendCommand(ByVal command As String) As Integer
' our communication command...

    Dim strSend As String
    Dim count As Long
   
    strSend = command + vbCrLf
   
    count = send(socketId, ByVal strSend, Len(strSend), 0)
   
    If count = SOCKET_ERROR Then
        MsgBox ("ERROR: send = " + Str$(count))
        SendCommand = COMMAND_ERROR
        Exit Function
    End If
   
    SendCommand = NO_ERROR

End Function

Function RecvAscii(dataBuf As String, ByVal maxLength As Integer) As Integer
On Error GoTo Error_Handler
DoEvents
Dim c As String * 12288
Dim length As Integer

dataBuf = ""
DoEvents
dataBuf = recv(socketId, c, 12288, 0)
dataBuf = c
length = Len(dataBuf)

Exit Function
Error_Handler:
DoEvents
MsgBox Err.Number & " " & Err.Description
DoEvents

End Function

Function initWinsock() As Boolean ' {

    Dim wsaVersion As Long
        wsaVersion = 257


    Dim rc  As Long
    Dim wsa As WSAData

    rc = WSAStartup(wsaVersion, wsa)

    If rc <> 0 Then
       initWinsock = False
       Exit Function
    End If

    initWinsock = True

End Function ' }


VBA Bas Code

Code: [Select]
Option Compare Database
Option Explicit
'This is the Winsock API definition file for Visual Basic

'Setup the variable type 'hostent' for
 the WSAStartup command
Type Hostent
  h_name As Long
  h_aliases As Long
  h_addrtype As String * 2
  h_length As String * 2
  h_addr_list As Long
End Type
Public Const SZHOSTENT = 16


'Set the Internet address type to a long integer (32-bit)
Type in_addr
   s_addr As Long
End Type


'A note to those familiar with the C header file for Winsock
'Visual Basic does not permit a user-defined variable type
'to be used as a return structure.  In the case of the
'variable definition below, sin_addr must
'be declared as a long integer rather than the user-defined
'variable type of in_addr.
Type sockaddr_in
   sin_family As Integer
   sin_port As Integer
   sin_addr As Long
   sin_zero As String * 8
End Type

Public Const WSADESCRIPTION_LEN = 256
Public Const WSASYS_STATUS_LEN = 128
Public Const WSA_DescriptionSize = WSADESCRIPTION_LEN + 1
Public Const WSA_SysStatusSize = WSASYS_STATUS_LEN + 1

'Setup the structure for the information returned from
'the WSAStartup() function.
Type WSAData
   wVersion As Integer
   wHighVersion As Integer
   szDescription As String * WSA_DescriptionSize
   szSystemStatus As String * WSA_SysStatusSize
   iMaxSockets As Integer
   iMaxUdpDg As Integer
   lpVendorInfo As String * 200
End Type

'Define socket return codes
Public Const INVALID_SOCKET = &HFFFF
Public Const SOCKET_ERROR = -1

'Define socket types
Public Const SOCK_STREAM = 1           'Stream socket
Public Const SOCK_DGRAM = 2            'Datagram socket
Public Const SOCK_RAW = 3              'Raw data socket
Public Const SOCK_RDM = 4              'Reliable Delivery socket
Public Const SOCK_SEQPACKET = 5        'Sequenced Packet socket


'Define address families
Public Const AF_UNSPEC = 0             'unspecified
Public Const AF_UNIX = 1               'local to host (pipes, portals)
Public Const AF_INET = 2               'internetwork: UDP, TCP, etc.
Public Const AF_IMPLINK = 3            'arpanet imp addresses
Public Const AF_PUP = 4                'pup protocols: e.g. BSP
Public Const AF_CHAOS = 5              'mit CHAOS protocols
Public Const AF_NS = 6                 'XEROX NS protocols
Public Const AF_ISO = 7                'ISO protocols
Public Const AF_OSI = AF_ISO           'OSI is ISO
Public Const AF_ECMA = 8               'european computer manufacturers
Public Const AF_DATAKIT = 9            'datakit protocols
Public Const AF_CCITT = 10             'CCITT protocols, X.25 etc
Public Const AF_SNA = 11               'IBM SNA
Public Const AF_DECnet = 12            'DECnet
Public Const AF_DLI = 13               'Direct data link interface
Public Const AF_LAT = 14               'LAT
Public Const AF_HYLINK = 15            'NSC Hyperchannel
Public Const AF_APPLETALK = 16         'AppleTalk
Public Const AF_NETBIOS = 17           'NetBios-style addresses
Public Const AF_MAX = 18               'Maximum # of address families


'Setup sockaddr data type to store Internet addresses
Type sockaddr
  sa_family As Integer
  sa_data As String * 14
End Type
Public Const SADDRLEN = 16


'Declare Socket functions

Public Declare PtrSafe Function closesocket Lib "wsock32.dll" (ByVal s As Long) As Long

Public Declare PtrSafe Function connect Lib "wsock32.dll" (ByVal s As Long, addr As sockaddr_in, ByVal namelen As Long) As Long

Public Declare PtrSafe Function htons Lib "wsock32.dll" (ByVal hostshort As Long) As Integer

Public Declare PtrSafe Function inet_addr Lib "wsock32.dll" (ByVal cp As String) As Long

Public Declare PtrSafe Function recv Lib "wsock32.dll" (ByVal s As Long, buf As Any, ByVal buflen As Long, ByVal flags As Long) As Long

Public Declare PtrSafe Function recvB Lib "wsock32.dll" Alias "recv" (ByVal s As Long, buf As Any, ByVal buflen As Long, ByVal flags As Long) As Long

Public Declare PtrSafe Function send Lib "wsock32.dll" (ByVal s As Long, buf As Any, ByVal buflen As Long, ByVal flags As Long) As Long

Public Declare PtrSafe Function socket Lib "wsock32.dll" (ByVal af As Long, ByVal socktype As Long, ByVal protocol As Long) As Long

Public Declare PtrSafe Function WSAStartup Lib "wsock32.dll" (ByVal wVersionRequired As Long, lpWSAdata As WSAData) As Long

Public Declare PtrSafe Function WSACleanup Lib "wsock32.dll" () As Long

Public Declare PtrSafe Function WSAUnhookBlockingHook Lib "wsock32.dll" () As Long

Public Declare PtrSafe Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (hpvDest As Any, hpvSource As Any, ByVal cbCopy As Long)
Public Declare PtrSafe Function setsockopt Lib "wsock32.dll" (ByVal s As Long, ByVal level As Long, ByVal optname As Long, optval As Long, ByVal optlen As Long) As Long
Global Const SO_RCVTIMEO = &H1006
Global Const SOL_SOCKET = &HFFFF&

Functions to call the above codes:



Code: [Select]
Call initWinsock
Call OpenSocket("192.168.1.197", 8888)
Dim lngStatus as long

lngStatus = SendCommand(strData)

Sleep Function

Code: [Select]
Dim ival As Long, sv As Long

ival = 1000    ' Time in milliseconds
sv = LenB(ival)
x = setsockopt(socketId, SOL_SOCKET, SO_RCVTIMEO, ival, LenB(sv))

Reading Data

' Read maximum of bytes from TCP/IP Port.Please note while 20 = Length
Code: [Select]
lngStatus = RecvAscii(strData, 60)

14
USB / Re: Should Feature Units define nothing for channels without controls?
« Last post by Jan Axelson on July 24, 2021, 09:35:15 pm »
The audio class spec says:

3.13.6 The Feature Unit (FU) is essentially a multi-channel processing unit that provides basic manipulation of multiple single-parameter Audio Controls on the incoming logical channels. For each logical channel, the Feature Unit optionally provides Audio Controls for the following features:
•   Mute
•   Volume
•   Tone Control (Bass, Mid, Treble)
•   Graphic Equalizer
•   Automatic Gain Control
•   Delay
•   Bass Boost
•   Loudness
•   Input Gain
•   Input Gain Pad
•   Phase Inverter
In addition, the Feature Unit optionally provides the above Audio Controls but now influencing all channels of the cluster at once. In this way, ‘master’ Controls can be implemented

The use of "optionally" to me says that a single control is sufficient.

I don't have direct experience with it however.
15
USB / Should Feature Units define nothing for channels without controls?
« Last post by jb on July 23, 2021, 04:19:56 pm »
If I have a stereo audio stream, and I want only a Master control for Volume/Mute in the Feature Unit (Master controls all channels simultaneously), do I need to define empty controls for the individual channels?

In other words, is this correct?

Code: [Select]
bmaControls:
 0x03    Channel(0) - Mute / Volume

Or should it properly be this?

Code: [Select]
bmaControls:
 0x03    Channel(0) - Mute / Volume
 0x00    Channel(1)
 0x00    Channel(2)

Both seem to work in various operating systems.
17
Very approximately...

Code: [Select]
   HANDLE hub;
   USB_NODE_CONNECTION_INFORMATION_EX info;

   for(i=1;;i++)
   {
      info.ConnectionIndex=i;
      flag=DeviceIoControl(hub, IOCTL_USB_GET_NODE_CONNECTION_INFORMATION_EX, &info, sizeof(info), &info, sizeof(info), &n, NULL);
      speed=info.Speed;

18
So that means that Windows would show 2 root hubs for a single XHCI controller: a USB3 and a USB2 (EHCI) root hub ?
19
A USB 3.1 hub contains both a USB 2.0 hub that supports low, full, and high speeds and an Enhanced SuperSpeed hub that contains a SuperSpeed hub and a Super-SpeedPlus hub. The USB 2.0 and Enhanced SuperSpeed hubs operate independently except for sharing logic to control VBUS. The host enumerates a USB 3.1 hub as two hubs.
20
As I saw when comparing USB 2 and USB 3 spec is that bit meanings have changed for the "Get Port Status" message.
Under USB 2.0, the port status bits contained bits for "low speed" and "high speed" (and if neither was set, it was full speed).

For USB 3.x, the port status bits contain a different 3-bit field that is always to be 0.

If you now have a port that supports Superspeed as well as Low/Full/Highspeed devices, how do you know what "variant" of return from "Get Port Status" you will get ? Or does a XHCI controller actually always have 2 completely separate hubs, one for USB 3.0 and yet another one for USB 2.0 with  even separate hub/device addresses ?

If I wanted to write a XHCI HC driver, would that then mean that that driver would actually need to support both, XHCI and EHCI ?



Pages: 1 [2] 3 4 ... 10