This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Problem with size of structers

Hi anybody

I declare the folowing stuctures:

typedef struct {
    ubyte	bLength;
    ubyte	bDescriptorType;
    ubyte	bInterfaceNumber;
    ubyte	bAlternateSetting;
    ubyte	bNumEndpoints;
    ubyte	bInterfaceClass;
    ubyte	bInterfaceSubClass;
    ubyte	bInterfaceProtocol;
    ubyte	iInterface;
} USB_interface_desc_t;

typedef struct {
    ubyte	bLength;
    ubyte	bDescriptorType;
    uword	wTotalLength;
    ubyte	bNumInterfaces;
    ubyte	bConfigurationValue;
    ubyte	iConfiguration;
    ubyte	bmAttributes;
    ubyte	MaxPower;
} USB_config_desc_t;


typedef struct {
    ubyte	bLength;
    ubyte	bDescriptorType;
    struct {
	ubyte address:4;
	ubyte reserved:3;
	ubyte direction:1;
    } bEndpointAddress;
    ubyte	bmAttributes;
    uword	wMaxPacketSize;
    ubyte	bInterval;
} USB_endpoint_desc_t;

typedef struct {
    USB_config_desc_t	usb_dev_config_desc;
    USB_interface_desc_t	usb_interface_0_alt_0_desc;
    USB_endpoint_desc_t	usb_dev_endpoint_alt_0_desc[2];
} USB_long_config_desc_t;

When I use the sizeof I obtain folowing values:

sizeof(USB_long_config_desc_t) = 0x24
sizeof(USB_endpoint_desc_t) = 0x08
sizeof(USB_interface_desc_t) = 0x09
sizeof(USB_config_desc_t) = 0x0A


What happens and what is wrong?

Thanks

Aram

Parents
  • If I understood it correctly, there are pad bytes in structures.
    But still there is a problem. I am trying to establish communication with
    PC (Windows 98) via USB port, and with this pad bytes I need to know
    how to do that if the first sizeof(USB_interface_desc_t) returns 0x09,
    but actually 10 bytes were sent and second sizeof(USB_endpoint_desc_t)
    in C166 returns 0x08, while on PC side this structure has size of 7 bytes,
    and standard Windows DDK function for USB can't properly receive
    Endpoints information.

    I need help ASAP!!!!!

Reply
  • If I understood it correctly, there are pad bytes in structures.
    But still there is a problem. I am trying to establish communication with
    PC (Windows 98) via USB port, and with this pad bytes I need to know
    how to do that if the first sizeof(USB_interface_desc_t) returns 0x09,
    but actually 10 bytes were sent and second sizeof(USB_endpoint_desc_t)
    in C166 returns 0x08, while on PC side this structure has size of 7 bytes,
    and standard Windows DDK function for USB can't properly receive
    Endpoints information.

    I need help ASAP!!!!!

Children