Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implemented settings module for storing AIOC settings #37

Closed
wants to merge 3 commits into from

Conversation

skuep
Copy link
Owner

@skuep skuep commented Sep 10, 2023

As discussed in issue #30.

The AIOC gains the functionality to be configurable from the host PC. Currently, it is possible to change the source for the PTT1 and PTT2 output pins.
The settings can be stored in the flash memory and they are automatically recalled on startup. But the implementation is sound.

Note that it is currently not well documented and rudimentary. Use the following example script to change the PTT1/PTT2 behaviour so that PTT1 is not used anymore and PTT2 is controlled with DTR=1 and RTS=0. This script requires hidapi to be installed. Note that I only tested this on Linux, should work on Windows too. It might be required to have root/Admin privileges.

python -m pip install hidapi (or python3 instead of python e.g. for Linux)

import hid
from struct import Struct
from enum import IntEnum, IntFlag

class Register(IntEnum):
    PTT1CTRL = 0x10
    PTT2CTRL = 0x11

class Command(IntFlag):
    DEFAULTS = 0x10
    RECALL = 0x40
    STORE = 0x80

class PTTSource(IntFlag):
    NONE = 0x00000000
    CM108GPIO1 = 0x00000100
    CM108GPIO2 = 0x00000200
    CM108GPIO3 = 0x00000400
    CM108GPIO4 = 0x00000800
    SERIALDTR = 0x00010000
    SERIALRTS = 0x00020000
    SERIALDTRNRTS = 0x00040000
    SERIALNDTRRTS = 0x00080000


def read(device, address):
    data = device.get_feature_report(int(address), 5)
    address, value = Struct('<BL').unpack(data)
    return value

def write(device, address, value):
    data = Struct('<BL').pack(address, value)
    device.send_feature_report(data)

aioc = hid.Device(vid=0x1209, pid=0x7388)

print(f'Manufacturer: {aioc.manufacturer}')
print(f'Product: {aioc.product}')
print(f'Serial No: {aioc.serial}')

print(f'Current PTT1 Source: {str(PTTSource(read(aioc, Register.PTT1CTRL)))}')
print(f'Current PTT2 Source: {str(PTTSource(read(aioc, Register.PTT2CTRL)))}')

if True: # Set to true to change PTT1 source
    ptt1_source = PTTSource.NONE
    print(f'Setting PTT1 Source to {str(ptt1_source)}')
    write(aioc, Register.PTT1CTRL, ptt1_source)

if True: # Set to true to change PTT2 source
    ptt2_source = PTTSource.SERIALDTRNRTS
    print(f'Setting PTT2 Source to {str(ptt2_source)}')
    write(aioc, Register.PTT2CTRL, ptt2_source)

print(f'Now PTT1 Source: {str(PTTSource(read(aioc, Register.PTT1CTRL)))}')
print(f'Now PTT2 Source: {str(PTTSource(read(aioc, Register.PTT2CTRL)))}')

if False: # Set to true to load defaults
    print(f'Loading Defaults...')
    write(aioc, 0, Command.DEFAULTS)

if True: # Set to true to store current settings
    print(f'Storing...')
    write(aioc, 0, Command.STORE)

Example Output is:

Manufacturer: AIOC
Product: All-In-One-Cable
Serial No: 4682fb53
Current PTT1 Source: PTTSource.SERIALDTRNRTS|CM108GPIO3
Current PTT2 Source: PTTSource.CM108GPIO4
Setting PTT1 Source to PTTSource.NONE
Setting PTT2 Source to PTTSource.SERIALDTRNRTS
Now PTT1 Source: PTTSource.NONE
Now PTT2 Source: PTTSource.SERIALDTRNRTS
Storing...

Here is a binary of the compiled firmware for you to test:
aioc-fw-configitf.bin.zip

@skuep
Copy link
Owner Author

skuep commented Dec 30, 2023

Merged in 6c9cfed

@skuep skuep closed this Dec 30, 2023
@skuep skuep deleted the configitf branch December 30, 2023 14:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant