Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Titan » RAW: Problem when including length field in LENGTHTO()
RAW: Problem when including length field in LENGTHTO() [message #1801091] Sun, 13 January 2019 11:56 Go to next message
Harald Welte is currently offline Harald WelteFriend
Messages: 106
Registered: July 2017
Location: Berlin, Germany
Senior Member

I've been trying to express USB Standard descriptors using the TITAN RAW codec (TITAN 6.5.0) and stumbled upon some behavior that I cannot explain.

Let's take the device descriptor as an example. I'm using '12011001FF11FF088A131700780000000101'O as a real-world example of the USB-attached fingerprint reader built into my laptop.

The following definition provides a working decode:
type integer uint8_t (0..255) with { variant "unsigned 8 bit" };
type octetstring OCT1 length(1) with { variant "FIELDLENGTH(1)" };
type octetstring OCT2 length(2) with { variant "FIELDLENGTH(2)" };
type record USB_DeviceDescriptor {
        uint8_t         bLength,
        OCT1            bDescriptorType,
        OCT2            bcdUSB,
        OCT1            bDeviceClass,
        OCT1            bDeviceSubClass,
        OCT1            bDeviceProtocol,
        uint8_t         bMaxPacketSize0,
        OCT2            idVendor,
        OCT2            idProduct,
        OCT2            bcdDevice,
        uint8_t         iManufacturer,
        uint8_t         iProduct,
        uint8_t         iSerialNumber,
        uint8_t         bNumConfigurations
};


Which renders the following correctly decoded output:
{ bLength := 18, bDescriptorType := '01'O, bcdUSB := '0110'O, bDeviceClass := 'FF'O, bDeviceSubClass := '11'O, bDeviceProtocol := 'FF'O, bMaxPacketSize0 := 8, idVendor := '138A'O, idProduct := '0017'O, bcdDevice := '0078'O, iManufacturer := 0, iProduct := 0, iSerialNumber := 1, bNumConfigurations := 1 }


however, if I amend the type definition with LENGTHTO(), like
type record USB_DeviceDescriptor {
        uint8_t         bLength,
        OCT1            bDescriptorType,
        OCT2            bcdUSB,
        OCT1            bDeviceClass,
        OCT1            bDeviceSubClass,
        OCT1            bDeviceProtocol,
        uint8_t         bMaxPacketSize0,
        OCT2            idVendor,
        OCT2            idProduct,
        OCT2            bcdDevice,
        uint8_t         iManufacturer,
        uint8_t         iProduct,
        uint8_t         iSerialNumber,
        uint8_t         bNumConfigurations
} with { variant (bLength) "LENGTHTO(bLength,bDescriptorType,bcdUSB,bDeviceClass,bcdUSB,bDeviceClass,
                                     bDeviceSubClass,bDeviceProtocol,bMaxPacketSize0,idVendor,idProduct,
                                     bcdDevice,iManufacturer,iProduct,iSerialNumber,bNumConfigurations)" };


then decoding fails with:
Dynamic test case error: While RAW-decoding type '@USB_Types.USB_DeviceDescriptor': There are not enough bits in the buffer to decode type @USB_Types.USB_DeviceDescriptor.iProduct (needed: 8, found: 0).


This is odd. The Titan Techincal Reference Guide clearly states that including the length field in LENGTHTO() is permitted. Yet, when I do so, it somehow fails to decode the message - despite the length value being 18 and the message being exactly 18 bytes long.

Even amending the uint8_t definition with variant "FIELDLENGTH(8)" doesn't change anything.

Any ideas? Am I missing something? Thanks!

[Updated on: Sun, 13 January 2019 12:05]

Report message to a moderator

Re: RAW: Problem when including length field in LENGTHTO() [message #1801092 is a reply to message #1801091] Sun, 13 January 2019 12:19 Go to previous messageGo to next message
Harald Welte is currently offline Harald WelteFriend
Messages: 106
Registered: July 2017
Location: Berlin, Germany
Senior Member

Nevermind the noise. The problem was that I listed some fields twice in:

} with { variant (bLength) "LENGTHTO(bLength,bDescriptorType,bcdUSB,bDeviceClass,bcdUSB,bDeviceClass,
                                     bDeviceSubClass,bDeviceProtocol,bMaxPacketSize0,idVendor,idProduct,
                                     bcdDevice,iManufacturer,iProduct,iSerialNumber,bNumConfigurations)" };


Specifically, bcdUSB and bDeviceClass were repeated.
Re: RAW: Problem when including length field in LENGTHTO() [message #1801095 is a reply to message #1801091] Sun, 13 January 2019 17:22 Go to previous message
Gábor Szalai is currently offline Gábor SzalaiFriend
Messages: 45
Registered: December 2015
Member
Yes if the field is listed twice than its length will used twice.

At least a warning should be issued in that case in the future.

Previous Topic:Statistic verdict for TTCN
Next Topic:Eclipse Titan release 6.5.0, intermediate release 6.5.1 announcements
Goto Forum:
  


Current Time: Mon Jul 06 06:40:44 GMT 2020

Powered by FUDForum. Page generated in 0.02495 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top