SceUsbSerial

From Vita Development Wiki
Jump to: navigation, search

Module

Known NIDs

Version Name World Privilege NID
1.69 SceUsbSerial Non-secure Kernel 0xF8D9930F

Libraries

Known NIDs

Version Name World Visibility NID
1.69 SceUsbSerialForDriver Non-secure Kernel 0x8829C2F3
1.69 SceUsbSerial Non-secure User 0x2820117D

SceUsbSerialForDriver

Activate USB serial device

Version NID
1.69 0xFEE7F4BA

The user is responsible for making sure no other UDC driver is active. This activates UDC as a "PS Vita" Type D device.

int SceUsbSerialForDriver_0xFEE7F4BA_start(void);

Setup USB serial device

Version NID
1.69 0x590B8F97
int SceUsbSerialForDriver_0x590B8F97_setup(int unk);

Get Device Status

Version NID
1.69 0x8C426906

Returns 1 when device is ready.

int SceUsbSerialForDriver_0x8C426906_status(void);

Close USB serial device

Version NID
1.69 0xE6B1E64F
int SceUsbSerialForDriver_0xE6B1E64F_close(void);

Get receive buffer length

Version NID
1.69 0xF531B5AE
unsigned int SceUsbSerialForDriver_0xF531B5AE_get_len(void);

Send Data

Version NID
1.69 0x0C2E73C0
unsigned int SceUsbSerialForDriver_0x0C2E73C0_send(const void *buffer, unsigned int len, int unk1, int unk2);

Receive Data

Version NID
1.69 0x6B5E296F
unsigned int SceUsbSerialForDriver_0x6B5E296F_recv(void *buffer, unsigned int max_len, int unk1, int unk2);

SceUsbSerial

Activate USB serial device

Version NID
1.69 0xE3BEC18C

User wrapper for 0xFEE7F4BA. Must have correct permissions to call.

Setup USB serial device

Version NID
1.69 0x290E08B4

User wrapper for 0x590B8F97. Must have correct permissions to call.

Get Device Status

Version NID
1.69 0xA6A2F5DE

User wrapper for 0x8C426906. Must have correct permissions to call.

Close USB serial device

Version NID
1.69 0xF2415853

User wrapper for 0xE6B1E64F. Must have correct permissions to call.

Get receive buffer length

Version NID
1.69 0xE8567A87

User wrapper for 0xF531B5AE. Must have correct permissions to call.

Send Data

Version NID
1.69 0x89E71202

User wrapper for 0x0C2E73C0. Must have correct permissions to call. Max length is 0x10000.

Receive Data

Version NID
1.69 0xF26DC8D8

User wrapper for 0x6B5E296F. Must have correct permissions to call. Max length is 0x10000.

Sample Usage

int usb_serial_connect(void)
{
    int ret;

    ret = SceUsbSerialForDriver_0x8C426906_status();
    printf("SceUsbSerialForDriver_0x8C426906_status: 0x%08X\n", ret);
    if (ret != 0x80244401)
    {
        printf("already connected\n");
        return 0;
    }

    ret = SceUsbSerialForDriver_0xFEE7F4BA_start();
    printf("SceUsbSerialForDriver_0xFEE7F4BA_start: 0x%08X\n", ret);
    ret = SceUsbSerialForDriver_0x590B8F97_setup(1);
    printf("SceUsbSerialForDriver_0x590B8F97_setup: 0x%08X\n", ret);

    if (ret == 0x80244403)
    {
        ret = SceUsbSerialForDriver_0x6AA4EFA4();
        printf("SceUsbSerialForDriver_0x6AA4EFA4: 0x%08X\n", ret);
        ret = SceUsbSerialForDriver_0x590B8F97_setup(1);
        printf("SceUsbSerialForDriver_0x590B8F97_setup: 0x%08X\n", ret);
    }

    while (SceUsbSerialForDriver_0x8C426906_status() != 1); // wait for ready

    return 0;
}

int usb_serial_close(void)
{
    int ret;

    ret = SceUsbSerialForDriver_0x6AA4EFA4();
    printf("SceUsbSerialForDriver_0x6AA4EFA4: 0x%08X\n", ret);
    ret = SceUsbSerialForDriver_0xE6B1E64F_close();
    printf("SceUsbSerialForDriver_0xE6B1E64F_close: 0x%08X\n", ret);

    return 0;
}

int usb_serial_send(const void *data, unsigned int len)
{
    int ret;

    ret = SceUsbSerialForDriver_0x0C2E73C0_send(data, len, 0, -1);
    printf("SceUsbSerialForDriver_0x0C2E73C0_send: 0x%08X\n");

    return ret;
}

int usb_serial_recv(void *data, unsigned int len)
{
    int ret;

    while (SceUsbSerialForDriver_0xF531B5AE_get_len() < len)
    {
        if (SceUsbSerialForDriver_0x8C426906_status() != 1)
        {
            return 0;
        }
    }

    ret = SceUsbSerialForDriver_0x6B5E296F_recv(data, len, 0, -1);
    printf("SceUsbSerialForDriver_0x6B5E296F_recv: 0x%08X\n");

    return ret;
}