Skip to content

on_transaction is not called for IN transactions #7

Description

@laoo

The issue concerns the same problem as #4 , but in a broader context. I'm developing an MTP device and also wanted to analyze MTP packets, and I encountered the same effect as in #4 . After further experimentation, I noticed that the problem is general - USB Packet Viewer does not call the on_transaction method for IN transactions if the device type differs from the implemented one.
I'm attaching very trivial example.

mtpsample.zip

The problem can be easily reproduced. Just please take usb_class_msc_bot.lua, add a function

local function log(message)
    local f = io.open("log.txt", "a")
    if f then
        f:write( message, "\n")
        f:close()
    end
end

replace at the bottom cls.bInterface* with:

cls.bInterfaceClass     = 0xff
cls.bInterfaceSubClass  = 0xff
cls.bInterfaceProtocol  = 0x00

and replace cls.on_transaction with:

function cls.on_transaction(self, param, data, needDetail, forceBegin)
    local addr, ep, pid, ack = param:byte(1), param:byte(2), param:byte(3), param:byte(4)
    log( "" .. ep )

    return macro_defs.RES_NONE
end

On my machine I get only

2
2
2
2
2

What means that only OUT transactions were logged.

Whereas if you reverse cls.bInterface* to original

cls.bInterfaceClass     = 0x08
cls.bInterfaceSubClass  = 0x06
cls.bInterfaceProtocol  = 0x50

and put a pendrive into the USB Packet Viewer you will get logs from both OUT and IN transactions. I get something like:

2
129
129
2
129
129
2
129
129
etc

Could you try to fix it please. It would help me developing my device a lot.
Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions