Configurare nod bazat pe CM108: Diferență între versiuni

De la YO3ITI
Sari la navigare Sari la căutare
Linia 36: Linia 36:


==Verificare stack HID (Human Interface Device)==
==Verificare stack HID (Human Interface Device)==
O verificare mai detaliată se poate face cu comanda
<syntaxhighlight lang="console">
tom@rpi-yo3iti:/etc/udev/rules.d $ lsusb -v -d 0d8c:0012
Bus 001 Device 003: ID 0d8c:0012 C-Media Electronics, Inc. USB Audio Device
Couldn't open device, some information will be missing
Device Descriptor:
  bLength                18
  bDescriptorType        1
  bcdUSB              1.10
  bDeviceClass            0
  bDeviceSubClass        0
  bDeviceProtocol        0
  bMaxPacketSize0        8
  idVendor          0x0d8c C-Media Electronics, Inc.
  idProduct          0x0012
  bcdDevice            1.00
  iManufacturer          1 C-Media Electronics Inc.
  iProduct                2 USB Audio Device
  iSerial                0
  bNumConfigurations      1
  Configuration Descriptor:
    bLength                9
    bDescriptorType        2
    wTotalLength      0x00e0
    bNumInterfaces          4
    bConfigurationValue    1
    iConfiguration          0
    bmAttributes        0x80
      (Bus Powered)
    MaxPower              500mA
    Interface Descriptor:
      bLength                9
      bDescriptorType        4
      bInterfaceNumber        0
      bAlternateSetting      0
      bNumEndpoints          0
      bInterfaceClass        1 Audio
      bInterfaceSubClass      1 Control Device
      bInterfaceProtocol      0
      iInterface              0
      AudioControl Interface Descriptor:
        bLength                10
        bDescriptorType        36
        bDescriptorSubtype      1 (HEADER)
        bcdADC              1.00
        wTotalLength      0x0047
        bInCollection          2
        baInterfaceNr(0)        1
        baInterfaceNr(1)        2
      AudioControl Interface Descriptor:
        bLength                12
        bDescriptorType        36
        bDescriptorSubtype      2 (INPUT_TERMINAL)
        bTerminalID            1
        wTerminalType      0x0101 USB Streaming
        bAssocTerminal          0
        bNrChannels            2
        wChannelConfig    0x0003
          Left Front (L)
          Right Front (R)
        iChannelNames          0
        iTerminal              0
      AudioControl Interface Descriptor:
        bLength                12
        bDescriptorType        36
        bDescriptorSubtype      2 (INPUT_TERMINAL)
        bTerminalID            2
        wTerminalType      0x0201 Microphone
        bAssocTerminal          0
        bNrChannels            1
        wChannelConfig    0x0001
          Left Front (L)
        iChannelNames          0
        iTerminal              0
      AudioControl Interface Descriptor:
        bLength                9
        bDescriptorType        36
        bDescriptorSubtype      3 (OUTPUT_TERMINAL)
        bTerminalID            6
        wTerminalType      0x0301 Speaker
        bAssocTerminal          0
        bSourceID              9
        iTerminal              0
      AudioControl Interface Descriptor:
        bLength                9
        bDescriptorType        36
        bDescriptorSubtype      3 (OUTPUT_TERMINAL)
        bTerminalID            7
        wTerminalType      0x0101 USB Streaming
        bAssocTerminal          0
        bSourceID              10
        iTerminal              0
      AudioControl Interface Descriptor:
        bLength                10
        bDescriptorType        36
        bDescriptorSubtype      6 (FEATURE_UNIT)
        bUnitID                9
        bSourceID              1
        bControlSize            1
        bmaControls(0)      0x01
          Mute Control
        bmaControls(1)      0x02
          Volume Control
        bmaControls(2)      0x02
          Volume Control
        iFeature                0
      AudioControl Interface Descriptor:
        bLength                9
        bDescriptorType        36
        bDescriptorSubtype      6 (FEATURE_UNIT)
        bUnitID                10
        bSourceID              2
        bControlSize            1
        bmaControls(0)      0x43
          Mute Control
          Volume Control
          Automatic Gain Control
        bmaControls(1)      0x00
        iFeature                0
    Interface Descriptor:
      bLength                9
      bDescriptorType        4
      bInterfaceNumber        1
      bAlternateSetting      0
      bNumEndpoints          0
      bInterfaceClass        1 Audio
      bInterfaceSubClass      2 Streaming
      bInterfaceProtocol      0
      iInterface              0
    Interface Descriptor:
      bLength                9
      bDescriptorType        4
      bInterfaceNumber        1
      bAlternateSetting      1
      bNumEndpoints          1
      bInterfaceClass        1 Audio
      bInterfaceSubClass      2 Streaming
      bInterfaceProtocol      0
      iInterface              0
      AudioStreaming Interface Descriptor:
        bLength                7
        bDescriptorType        36
        bDescriptorSubtype      1 (AS_GENERAL)
        bTerminalLink          1
        bDelay                  1 frames
        wFormatTag        0x0001 PCM
      AudioStreaming Interface Descriptor:
        bLength                14
        bDescriptorType        36
        bDescriptorSubtype      2 (FORMAT_TYPE)
        bFormatType            1 (FORMAT_TYPE_I)
        bNrChannels            2
        bSubframeSize          2
        bBitResolution        16
        bSamFreqType            2 Discrete
        tSamFreq[ 0]        48000
        tSamFreq[ 1]        44100
      Endpoint Descriptor:
        bLength                9
        bDescriptorType        5
        bEndpointAddress    0x01  EP 1 OUT
        bmAttributes            9
          Transfer Type            Isochronous
          Synch Type              Adaptive
          Usage Type              Data
        wMaxPacketSize    0x00c8  1x 200 bytes
        bInterval              1
        bRefresh                0
        bSynchAddress          0
        AudioStreaming Endpoint Descriptor:
          bLength                7
          bDescriptorType        37
          bDescriptorSubtype      1 (EP_GENERAL)
          bmAttributes        0x01
            Sampling Frequency
          bLockDelayUnits        1 Milliseconds
          wLockDelay        0x0001
    Interface Descriptor:
      bLength                9
      bDescriptorType        4
      bInterfaceNumber        2
      bAlternateSetting      0
      bNumEndpoints          0
      bInterfaceClass        1 Audio
      bInterfaceSubClass      2 Streaming
      bInterfaceProtocol      0
      iInterface              0
    Interface Descriptor:
      bLength                9
      bDescriptorType        4
      bInterfaceNumber        2
      bAlternateSetting      1
      bNumEndpoints          1
      bInterfaceClass        1 Audio
      bInterfaceSubClass      2 Streaming
      bInterfaceProtocol      0
      iInterface              0
      AudioStreaming Interface Descriptor:
        bLength                7
        bDescriptorType        36
        bDescriptorSubtype      1 (AS_GENERAL)
        bTerminalLink          7
        bDelay                  1 frames
        wFormatTag        0x0001 PCM
      AudioStreaming Interface Descriptor:
        bLength                14
        bDescriptorType        36
        bDescriptorSubtype      2 (FORMAT_TYPE)
        bFormatType            1 (FORMAT_TYPE_I)
        bNrChannels            1
        bSubframeSize          2
        bBitResolution        16
        bSamFreqType            2 Discrete
        tSamFreq[ 0]        48000
        tSamFreq[ 1]        44100
      Endpoint Descriptor:
        bLength                9
        bDescriptorType        5
        bEndpointAddress    0x82  EP 2 IN
        bmAttributes          13
          Transfer Type            Isochronous
          Synch Type              Synchronous
          Usage Type              Data
        wMaxPacketSize    0x0064  1x 100 bytes
        bInterval              1
        bRefresh                0
        bSynchAddress          0
        AudioStreaming Endpoint Descriptor:
          bLength                7
          bDescriptorType        37
          bDescriptorSubtype      1 (EP_GENERAL)
          bmAttributes        0x01
            Sampling Frequency
          bLockDelayUnits        0 Undefined
          wLockDelay        0x0000
    Interface Descriptor:
      bLength                9
      bDescriptorType        4
      bInterfaceNumber        3
      bAlternateSetting      0
      bNumEndpoints          1
      bInterfaceClass        3 Human Interface Device
      bInterfaceSubClass      0
      bInterfaceProtocol      0
      iInterface              0
        HID Device Descriptor:
          bLength                9
          bDescriptorType        33
          bcdHID              1.00
          bCountryCode            0 Not supported
          bNumDescriptors        1
          bDescriptorType        34 Report
          wDescriptorLength      60
        Report Descriptors:
          ** UNAVAILABLE **
      Endpoint Descriptor:
        bLength                7
        bDescriptorType        5
        bEndpointAddress    0x87  EP 7 IN
        bmAttributes            3
          Transfer Type            Interrupt
          Synch Type              None
          Usage Type              Data
        wMaxPacketSize    0x0004  1x 4 bytes
        bInterval              2
</syntaxhighlight>


=Setarea regulilor în <code>udev</code>=
=Setarea regulilor în <code>udev</code>=

Versiunea de la data 1 august 2025 23:42

Introducere

Pentru secțiunea principală legată de instalarea și configurarea svxlink, vezi acest link.

Verificări hardware

Verificare recunoaștere chip CM108

După conectarea fizică (prin lipire) a pinilor D+ și D- în paralel cu port-ul USB 2.0 al plăcii-mamă, trebuie verificat că sistemul recunoaște chip-ul CM108 ca subsistem audio.

Se rulează comanda lsusb:

tom@raspberrypi:~ $ lsusb

În răspunsul sistemului trebuie să se regăsească C-Media Electronics, Inc. USB Audio Device:

tom@raspberrypi:~ $ lsusb
Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 001 Device 003: ID 0d8c:0012 C-Media Electronics, Inc. USB Audio Device
Bus 001 Device 002: ID 2109:3431 VIA Labs, Inc. Hub
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

Ia aminte la VID și PID (vendor ID și Product ID 0d8c:0012. Aceste informații trebuie folosite la crearea regulilor din udev.

Verificarea se mai poate face și cu comanda cat:

tom@raspberrypi:~ $ cat /proc/asound/cards
 0 [Device         ]: USB-Audio - USB Audio Device
                      C-Media Electronics Inc. USB Audio Device at usb-0000:01:00.0-1.3, full speed

Verificare stack HID (Human Interface Device)

O verificare mai detaliată se poate face cu comanda

tom@rpi-yo3iti:/etc/udev/rules.d $ lsusb -v -d 0d8c:0012

Bus 001 Device 003: ID 0d8c:0012 C-Media Electronics, Inc. USB Audio Device
Couldn't open device, some information will be missing
Device Descriptor:
  bLength                18
  bDescriptorType         1
  bcdUSB               1.10
  bDeviceClass            0 
  bDeviceSubClass         0 
  bDeviceProtocol         0 
  bMaxPacketSize0         8
  idVendor           0x0d8c C-Media Electronics, Inc.
  idProduct          0x0012 
  bcdDevice            1.00
  iManufacturer           1 C-Media Electronics Inc.
  iProduct                2 USB Audio Device
  iSerial                 0 
  bNumConfigurations      1
  Configuration Descriptor:
    bLength                 9
    bDescriptorType         2
    wTotalLength       0x00e0
    bNumInterfaces          4
    bConfigurationValue     1
    iConfiguration          0 
    bmAttributes         0x80
      (Bus Powered)
    MaxPower              500mA
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        0
      bAlternateSetting       0
      bNumEndpoints           0
      bInterfaceClass         1 Audio
      bInterfaceSubClass      1 Control Device
      bInterfaceProtocol      0 
      iInterface              0 
      AudioControl Interface Descriptor:
        bLength                10
        bDescriptorType        36
        bDescriptorSubtype      1 (HEADER)
        bcdADC               1.00
        wTotalLength       0x0047
        bInCollection           2
        baInterfaceNr(0)        1
        baInterfaceNr(1)        2
      AudioControl Interface Descriptor:
        bLength                12
        bDescriptorType        36
        bDescriptorSubtype      2 (INPUT_TERMINAL)
        bTerminalID             1
        wTerminalType      0x0101 USB Streaming
        bAssocTerminal          0
        bNrChannels             2
        wChannelConfig     0x0003
          Left Front (L)
          Right Front (R)
        iChannelNames           0 
        iTerminal               0 
      AudioControl Interface Descriptor:
        bLength                12
        bDescriptorType        36
        bDescriptorSubtype      2 (INPUT_TERMINAL)
        bTerminalID             2
        wTerminalType      0x0201 Microphone
        bAssocTerminal          0
        bNrChannels             1
        wChannelConfig     0x0001
          Left Front (L)
        iChannelNames           0 
        iTerminal               0 
      AudioControl Interface Descriptor:
        bLength                 9
        bDescriptorType        36
        bDescriptorSubtype      3 (OUTPUT_TERMINAL)
        bTerminalID             6
        wTerminalType      0x0301 Speaker
        bAssocTerminal          0
        bSourceID               9
        iTerminal               0 
      AudioControl Interface Descriptor:
        bLength                 9
        bDescriptorType        36
        bDescriptorSubtype      3 (OUTPUT_TERMINAL)
        bTerminalID             7
        wTerminalType      0x0101 USB Streaming
        bAssocTerminal          0
        bSourceID              10
        iTerminal               0 
      AudioControl Interface Descriptor:
        bLength                10
        bDescriptorType        36
        bDescriptorSubtype      6 (FEATURE_UNIT)
        bUnitID                 9
        bSourceID               1
        bControlSize            1
        bmaControls(0)       0x01
          Mute Control
        bmaControls(1)       0x02
          Volume Control
        bmaControls(2)       0x02
          Volume Control
        iFeature                0 
      AudioControl Interface Descriptor:
        bLength                 9
        bDescriptorType        36
        bDescriptorSubtype      6 (FEATURE_UNIT)
        bUnitID                10
        bSourceID               2
        bControlSize            1
        bmaControls(0)       0x43
          Mute Control
          Volume Control
          Automatic Gain Control
        bmaControls(1)       0x00
        iFeature                0 
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        1
      bAlternateSetting       0
      bNumEndpoints           0
      bInterfaceClass         1 Audio
      bInterfaceSubClass      2 Streaming
      bInterfaceProtocol      0 
      iInterface              0 
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        1
      bAlternateSetting       1
      bNumEndpoints           1
      bInterfaceClass         1 Audio
      bInterfaceSubClass      2 Streaming
      bInterfaceProtocol      0 
      iInterface              0 
      AudioStreaming Interface Descriptor:
        bLength                 7
        bDescriptorType        36
        bDescriptorSubtype      1 (AS_GENERAL)
        bTerminalLink           1
        bDelay                  1 frames
        wFormatTag         0x0001 PCM
      AudioStreaming Interface Descriptor:
        bLength                14
        bDescriptorType        36
        bDescriptorSubtype      2 (FORMAT_TYPE)
        bFormatType             1 (FORMAT_TYPE_I)
        bNrChannels             2
        bSubframeSize           2
        bBitResolution         16
        bSamFreqType            2 Discrete
        tSamFreq[ 0]        48000
        tSamFreq[ 1]        44100
      Endpoint Descriptor:
        bLength                 9
        bDescriptorType         5
        bEndpointAddress     0x01  EP 1 OUT
        bmAttributes            9
          Transfer Type            Isochronous
          Synch Type               Adaptive
          Usage Type               Data
        wMaxPacketSize     0x00c8  1x 200 bytes
        bInterval               1
        bRefresh                0
        bSynchAddress           0
        AudioStreaming Endpoint Descriptor:
          bLength                 7
          bDescriptorType        37
          bDescriptorSubtype      1 (EP_GENERAL)
          bmAttributes         0x01
            Sampling Frequency
          bLockDelayUnits         1 Milliseconds
          wLockDelay         0x0001
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        2
      bAlternateSetting       0
      bNumEndpoints           0
      bInterfaceClass         1 Audio
      bInterfaceSubClass      2 Streaming
      bInterfaceProtocol      0 
      iInterface              0 
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        2
      bAlternateSetting       1
      bNumEndpoints           1
      bInterfaceClass         1 Audio
      bInterfaceSubClass      2 Streaming
      bInterfaceProtocol      0 
      iInterface              0 
      AudioStreaming Interface Descriptor:
        bLength                 7
        bDescriptorType        36
        bDescriptorSubtype      1 (AS_GENERAL)
        bTerminalLink           7
        bDelay                  1 frames
        wFormatTag         0x0001 PCM
      AudioStreaming Interface Descriptor:
        bLength                14
        bDescriptorType        36
        bDescriptorSubtype      2 (FORMAT_TYPE)
        bFormatType             1 (FORMAT_TYPE_I)
        bNrChannels             1
        bSubframeSize           2
        bBitResolution         16
        bSamFreqType            2 Discrete
        tSamFreq[ 0]        48000
        tSamFreq[ 1]        44100
      Endpoint Descriptor:
        bLength                 9
        bDescriptorType         5
        bEndpointAddress     0x82  EP 2 IN
        bmAttributes           13
          Transfer Type            Isochronous
          Synch Type               Synchronous
          Usage Type               Data
        wMaxPacketSize     0x0064  1x 100 bytes
        bInterval               1
        bRefresh                0
        bSynchAddress           0
        AudioStreaming Endpoint Descriptor:
          bLength                 7
          bDescriptorType        37
          bDescriptorSubtype      1 (EP_GENERAL)
          bmAttributes         0x01
            Sampling Frequency
          bLockDelayUnits         0 Undefined
          wLockDelay         0x0000
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        3
      bAlternateSetting       0
      bNumEndpoints           1
      bInterfaceClass         3 Human Interface Device
      bInterfaceSubClass      0 
      bInterfaceProtocol      0 
      iInterface              0 
        HID Device Descriptor:
          bLength                 9
          bDescriptorType        33
          bcdHID               1.00
          bCountryCode            0 Not supported
          bNumDescriptors         1
          bDescriptorType        34 Report
          wDescriptorLength      60
         Report Descriptors: 
           ** UNAVAILABLE **
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x87  EP 7 IN
        bmAttributes            3
          Transfer Type            Interrupt
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0004  1x 4 bytes
        bInterval               2

Setarea regulilor în udev

udev este un subsistem Linux pentru gestionarea evenimentelor-dispozitiv. Pentru utilizarea nodurilor bazate pe CM108 prin intermediul HIDRAW, este necesarea crearea unor reguli de gestionare a evenimentelor legate de acest dispozitiv.

Creare fișier reguli

Pentru nodurile realizate cu CM108 trebuie creat un fișier de reguli în udev pentru a încărca modului CM108 ca dispozitiv audio hidraw

# block pulseaudio using the soundcard for SVXLINK
# astea sunt foarte importante
ATTRS{idVendor}=="0d8c", ATTRS{idProduct}=="013c", ENV{PULSE_IGNORE}="1"
ATTRS{idVendor}=="0d8c", ATTRS{idProduct}=="000c", ENV{PULSE_IGNORE}="1"
ATTRS{idVendor}=="0d8c", ATTRS{idProduct}=="0012", ENV{PULSE_IGNORE}="1"
# create a symlink /dev/hidrawX to /dev/cm108gpio
SUBSYSTEM=="hidraw", ATTRS{idVendor}=="0d8c", ATTRS{idProduct}=="013c", SYMLINK+="my_custom_dev_entry", MODE="0666"
# 0d8c:000c
SUBSYSTEM=="hidraw", ATTRS{idVendor}=="0d8c", ATTRS{idProduct}=="000c", SYMLINK+="my_custom_dev_entry", MODE="0666"
# 0d8c:0012 CM108B
SUBSYSTEM=="hidraw", ATTRS{idVendor}=="0d8c", ATTRS{idProduct}=="0012", SYMLINK+="my_custom_dev_entry", MODE="0666"

Secvența ATTRS{idVendor}=="0d8c", ATTRS{idProduct}=="0012" trebuie să corespundă cu informația dată de lsusb. Eu folosesc doar liniile evidențiate.

În cazul meu, creez un fișier în /etc/udev/rules.d. L-am numit 55-cm108.rules. Numărul de la începutul denumirii asigură prioritatea. Acest fișier conține:

# block pulseaudio using the soundcard for SVXLINK
# astea sunt foarte importante
ATTRS{idVendor}=="0d8c", ATTRS{idProduct}=="0012", ENV{PULSE_IGNORE}="1"
# creez un symlink /dev/hidrawX la /dev/yo3iti
# 0d8c:0012 CM108B
SUBSYSTEM=="hidraw", ATTRS{idVendor}=="0d8c", ATTRS{idProduct}=="0012", SYMLINK+="yo3iti", MODE="0666"

Actualizarea udev se face cu comanda:

tom@raspberrypi:~ $ sudo udevadm control --reload-rules && sudo udevadm trigger

Setări svxlink.conf

Nodul poate fi configurat doar pentru conectare la Echolink. Trebuie eliminată intrarea ReflectorLogic din secțiunea [GLOBAL] a fișierului de configurare:

[GLOBAL]
...
LOGICS=SimplexLogic
#,ReflectorLogic
...
TIMESTAMP_FORMAT="%Y-%m-%d %H:%M:%S"
CARD_SAMPLE_RATE=48000
CARD_CHANNELS=1
#LINKS=ReflectorLink
LOCATION_INFO=LocationInfo

Configurarea Tx și Rx

Apoi se modifică secțiunile Rx și Tx cu setările necesare pentru hidraw:

[Rx1]
...
SQL_DET=HIDRAW
HID_DEVICE=/dev/yo3iti
HID_SQL_PIN=VOL_DN
...
[Tx1]
...
PTT_TYPE=Hidraw
HID_DEVICE=/dev/yo3iti
HID_PTT_PIN=GPIO3
...

Unde my_custom_dev_entry e setarea din udev. Grijă la utilizarea majusculelor pentru SQL_DET și PTT_TYPE

sudo udevadm control --reload-rules && sudo udevadm trigger

Link-uri externe