Why does escpos hang when trying to connect to printer? - escpos

I have a SureMark 4610 printer that I'm trying to connect to, but for some reason it hangs when I connect. I've installed the necessary drivers for the printer. What could be the problem?
I'm using Windows 10 if that is of any use to you all.
Here's the printer device info
DEVICE ID 04b3:4535 on Bus 000 Address 019 =================
bLength : 0x12 (18 bytes)
bDescriptorType : 0x1 Device
bcdUSB : 0x110 USB 1.1
bDeviceClass : 0x0 Specified at interface
bDeviceSubClass : 0x0
bDeviceProtocol : 0x0
bMaxPacketSize0 : 0x40 (64 bytes)
idVendor : 0x04b3
idProduct : 0x4535
bcdDevice : 0x216 Device 2.16
iManufacturer : 0x1 (c) Copyright IBM Corp. 2000
iProduct : 0x5 Printer Interface (Usage = 3500h, Usage Page = FF45h)
iSerialNumber : 0x3 060725163603C100193
bNumConfigurations : 0x1
CONFIGURATION 1: 0 mA ====================================
bLength : 0x9 (9 bytes)
bDescriptorType : 0x2 Configuration
wTotalLength : 0x22 (34 bytes)
bNumInterfaces : 0x1
bConfigurationValue : 0x1
iConfiguration : 0x0
bmAttributes : 0x40 Self Powered
bMaxPower : 0x0 (0 mA)
INTERFACE 1: Human Interface Device ====================
bLength : 0x9 (9 bytes)
bDescriptorType : 0x4 Interface
bInterfaceNumber : 0x1
bAlternateSetting : 0x0
bNumEndpoints : 0x1
bInterfaceClass : 0x3 Human Interface Device
bInterfaceSubClass : 0x0
bInterfaceProtocol : 0x0
iInterface : 0x5 Printer Interface (Usage = 3500h, Usage Page = FF45h)
ENDPOINT 0x82: Interrupt IN ==========================
bLength : 0x7 (7 bytes)
bDescriptorType : 0x5 Endpoint
bEndpointAddress : 0x82 IN
bmAttributes : 0x3 Interrupt
wMaxPacketSize : 0x10 (16 bytes)
bInterval : 0x4
Here is the simple code
from escpos import printer
p = printer.Usb(idVendor=0x04B3, idProduct=0x4535, timeout=10, in_ep=0x82)
print(p.idProduct)
I cannot get to the print because it just hangs indefinitely at line 2.

Related

Make a monocolor jpeg file encoded one bit per pixel?

For example, I see the following output. I don't quite understand its complete meaning. But when I look at the figure, it is just black and white, without gray or other color.
$ file 0447.jpg
0447.jpg: JPEG image data, JFIF standard 1.01, aspect ratio, density 1x1, segment length 16, baseline, precision 8, 1725x2751, components 1
The file size is 652708. To encode, 1725x2751 bits, the file size should be no more than 1725 * 2751/8 = 593184.4. But the file size is bigger than this.
So it seems that a pixel is not encoded as one bit. Is there a way to shrink the size of the file (without loss of info) so that one pixel is one bit (maybe using other formats)?
Don't use IM identify to find the actual bits-per pixel. Use EXIFTOOL.
Input JPG:
Exiftool shows BitsPerSample of 8
exiftool -s -ee -g1 -u -n -D cow.jpg
---- ExifTool ----
- ExifToolVersion : 12.44
---- System ----
- FileName : cow.jpg
- Directory : .
- FileSize : 16214
- FileModifyDate : 2022:10:14 11:31:44-07:00
- FileAccessDate : 2022:10:14 11:31:44-07:00
- FileInodeChangeDate : 2022:10:14 11:31:44-07:00
- FilePermissions : 100644
---- File ----
- FileType : JPEG
- FileTypeExtension : JPG
- MIMEType : image/jpeg
- ImageWidth : 300
- ImageHeight : 300
- EncodingProcess : 0
- BitsPerSample : 8 <-------
- ColorComponents : 1
---- JFIF ----
0 JFIFVersion : 1 1
2 ResolutionUnit : 2
3 XResolution : 28
5 YResolution : 28
---- Composite ----
- ImageSize : 300 300
- Megapixels : 0.09
Threshold to GIF:
convert cow.jpg -threshold 50% cow_bw1.gif
Exiftool shows BitsPerPixel = 1
exiftool -s -ee -g1 -u -n -D cow_bw1.gif
---- ExifTool ----
- ExifToolVersion : 12.44
---- System ----
- FileName : cow_bw1.gif
- Directory : .
- FileSize : 2698
- FileModifyDate : 2022:10:14 11:44:17-07:00
- FileAccessDate : 2022:10:14 11:44:19-07:00
- FileInodeChangeDate : 2022:10:14 11:44:17-07:00
- FilePermissions : 100644
---- File ----
- FileType : GIF
- FileTypeExtension : GIF
- MIMEType : image/gif
---- GIF ----
- GIFVersion : 89a
0 ImageWidth : 300
2 ImageHeight : 300
4.1 HasColorMap : 1
4.2 ColorResolutionDepth : 8
4.3 BitsPerPixel : 1 <-------
5 BackgroundColor : 1
---- Composite ----
- ImageSize : 300 300
- Megapixels : 0.09
Threshold to PNG:
convert cow.jpg -threshold 50% cow_bw1.png
Exiftool shows BitDepth of 1
exiftool -s -ee -g1 -u -n -D cow_bw1.png
---- ExifTool ----
- ExifToolVersion : 12.44
- Warning : [minor] Text/EXIF chunk(s) found after PNG IDAT (may be ignored by some readers)
---- System ----
- FileName : cow_bw1.png
- Directory : .
- FileSize : 2251
- FileModifyDate : 2022:10:14 11:49:20-07:00
- FileAccessDate : 2022:10:14 11:49:21-07:00
- FileInodeChangeDate : 2022:10:14 11:49:20-07:00
- FilePermissions : 100644
---- File ----
- FileType : PNG
- FileTypeExtension : PNG
- MIMEType : image/png
---- PNG ----
0 ImageWidth : 300
4 ImageHeight : 300
8 BitDepth : 1 <-------
9 ColorType : 0
10 Compression : 0
11 Filter : 0
12 Interlace : 0
- Gamma : 2.2
- BackgroundColor : 1
- ModifyDate : 2022:10:14 18:49:20
- Datecreate : 2022-10-14T18:31:44+00:00
- Datemodify : 2022-10-14T18:31:44+00:00
- Datetimestamp : 2022-10-14T18:49:19+00:00
---- PNG-pHYs ----
0 PixelsPerUnitX : 2800
4 PixelsPerUnitY : 2800
8 PixelUnits : 1
---- Composite ----
- ImageSize : 300 300
- Megapixels : 0.09
ADDITION
Here is how to make a 2-bit TIFF file.
convert lena.jpg -colorspace gray -depth 2 -type palette lena_d2.tif
exiftool -s -ee -g1 -u -n -D lena_d2.tif
---- ExifTool ----
- ExifToolVersion : 12.44
---- System ----
- FileName : lena_d2.tif
- Directory : .
- FileSize : 16642
- FileModifyDate : 2022:10:14 16:42:42-07:00
- FileAccessDate : 2022:10:14 16:42:43-07:00
- FileInodeChangeDate : 2022:10:14 16:42:42-07:00
- FilePermissions : 100644
---- File ----
- FileType : TIFF
- FileTypeExtension : TIF
- MIMEType : image/tiff
- ExifByteOrder : II
---- IFD0 ----
256 ImageWidth : 256
257 ImageHeight : 256
258 BitsPerSample : 2 <------
259 Compression : 1
262 PhotometricInterpretation : 3
266 FillOrder : 1
273 StripOffsets : 8
274 Orientation : 1
277 SamplesPerPixel : 1
278 RowsPerStrip : 256
279 StripByteCounts : 16384
282 XResolution : 72
283 YResolution : 72
284 PlanarConfiguration : 1
296 ResolutionUnit : 2
297 PageNumber : 0 1
320 ColorMap : (Binary data 24 bytes, use -b option to extract)
---- Composite ----
- ImageSize : 256 256
- Megapixels : 0.065536

ESP8266-12F WiFi soft AP config.authmode failed

For a project I try do use the ESP8266 RTOS SDK.
First step I install the tools and the toolchain. The hello_world example and the other gpio example works fine. I try the softAP example and get a Guru Meditation Error: Core 0 panic'ed (StoreProhibited). Exception was unhandled Error. I figured out that the line 62 : .automode = WIFI_AUTH_WPA_WPA2_PSK not works. I tried WIFI_AUTH_WEP,WIFI_AUTH_WPA_PSK,WIFI_AUTH_WPA2_PSK but only with WIFI_AUTH_OPEN the softAP works. Anyone same behavior or some tips?
Console Trace:
ets Jan 8 2013,rst cause:1, boot mode:(3,6)
load 0x40100000, len 7040, room 16
tail 0
chksum 0xe5
load 0x3ffe8408, len 24, room 8
tail 0
chksum 0x6c
load 0x3ffe8420, len 3312, room 8
tail 8
chksum 0x75
csum 0x75
I (123) boot: ESP-IDF v3.4-rc 2nd stage bootloader
I (123) boot: compile time 19:41:32
I (207) qio_mode: Enabling default flash chip QIO
I (207) boot: SPI Speed : 40MHz
I (208) boot: SPI Mode : QOUT
I (212) boot: SPI Flash Size : 2MB
I (219) boot: Partition Table:
I (224) boot: ## Label Usage Type ST Offset Length
I (236) boot: 0 nvs WiFi data 01 02 00009000 00006000
I (247) boot: 1 phy_init RF data 01 01 0000f000 00001000
I (259) boot: 2 factory factory app 00 00 00010000 000f0000
I (271) boot: End of partition table
I (277) esp_image: segment 0: paddr=0x00010010 vaddr=0x40210010 size=0x52c80 (339072) map
I (406) esp_image: segment 1: paddr=0x00062c98 vaddr=0x40262c90 size=0x0f594 ( 62868) map
I (428) esp_image: segment 2: paddr=0x00072234 vaddr=0x3ffe8000 size=0x005fc ( 1532) load
I (429) esp_image: segment 3: paddr=0x00072838 vaddr=0x40100000 size=0x00080 ( 128) load
I (439) esp_image: segment 4: paddr=0x000728c0 vaddr=0x40100080 size=0x05560 ( 21856) load
I (460) boot: Loaded app from partition at offset 0x10000
I (481) wifi softAP: ESP_WIFI_MODE_AP
I (484) system_api: Base MAC address is not set, read default base MAC address from EFUSE
I (486) system_api: Base MAC address is not set, read default base MAC address from EFUSE
phy_version: 1163.0, 665d56c, Jun 24 2020, 10:00:08, RTOS new
I (557) phy_init: phy ver: 1163_0
I (567) wifi softAP: ----------------###------------
ESP_ERROR_CHECK failed: esp_err_t 0x2 (ERROR) at 0x4021f7cc
file: "softap_example_main.c" line 73
func: wifi_init_softap
expression: esp_wifi_set_config(ESP_IF_WIFI_AP, &wifi_config)
abort() was called at PC 0x4021f7cf on core 0
Guru Meditation Error: Core 0 panic'ed (StoreProhibited). Exception was unhandled.
Core 0 register dump:
PC : 0x40221c72 PS : 0x00000030 A0 : 0x40221c70 A1 : 0x3ffeb550
A2 : 0x00000000 A3 : 0xffffffdb A4 : 0x00000001 A5 : 0x00000001
A6 : 0x00000000 A7 : 0x4026663c A8 : 0x00000020 A9 : 0x00000000
A10 : 0x00000008 A11 : 0x00000000 A12 : 0x00000000 A13 : 0x00000000
A14 : 0x00000000 A15 : 0x00000000 SAR : 0x0000001e EXCCAUSE: 0x0000001d
Backtrace: 0x40221c72:0x3ffeb550 0x4021f7d2:0x3ffeb560 0x4022182e:0x3ffeb570 0x40221894:0x3ffeb630 0x402118ef:0x3ffeb640
Example Code from GitHub: (examples/wifi/getting_started/softAP/main/softap_example_main.c)
/* WiFi softAP Example
This example code is in the Public Domain (or CC0 licensed, at your option.)
Unless required by applicable law or agreed to in writing, this
software is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
CONDITIONS OF ANY KIND, either express or implied.
*/
#include <string.h>
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "esp_system.h"
#include "esp_wifi.h"
#include "esp_event.h"
#include "esp_log.h"
#include "nvs_flash.h"
#include "lwip/err.h"
#include "lwip/sys.h"
/* The examples use WiFi configuration that you can set via project configuration menu.
If you'd rather not, just change the below entries to strings with
the config you want - ie #define EXAMPLE_WIFI_SSID "mywifissid"
*/
#define EXAMPLE_ESP_WIFI_SSID CONFIG_ESP_WIFI_SSID
#define EXAMPLE_ESP_WIFI_PASS CONFIG_ESP_WIFI_PASSWORD
#define EXAMPLE_MAX_STA_CONN CONFIG_ESP_MAX_STA_CONN
static const char *TAG = "wifi softAP";
static void wifi_event_handler(void* arg, esp_event_base_t event_base,
int32_t event_id, void* event_data)
{
if (event_id == WIFI_EVENT_AP_STACONNECTED) {
wifi_event_ap_staconnected_t* event = (wifi_event_ap_staconnected_t*) event_data;
ESP_LOGI(TAG, "station "MACSTR" join, AID=%d",
MAC2STR(event->mac), event->aid);
} else if (event_id == WIFI_EVENT_AP_STADISCONNECTED) {
wifi_event_ap_stadisconnected_t* event = (wifi_event_ap_stadisconnected_t*) event_data;
ESP_LOGI(TAG, "station "MACSTR" leave, AID=%d",
MAC2STR(event->mac), event->aid);
}
}
void wifi_init_softap()
{
tcpip_adapter_init();
ESP_ERROR_CHECK(esp_event_loop_create_default());
wifi_init_config_t cfg = WIFI_INIT_CONFIG_DEFAULT();
ESP_ERROR_CHECK(esp_wifi_init(&cfg));
ESP_ERROR_CHECK(esp_event_handler_register(WIFI_EVENT, ESP_EVENT_ANY_ID, &wifi_event_handler, NULL));
wifi_config_t wifi_config = {
.ap = {
.ssid = EXAMPLE_ESP_WIFI_SSID,
.ssid_len = strlen(EXAMPLE_ESP_WIFI_SSID),
.password = EXAMPLE_ESP_WIFI_PASS,
.max_connection = EXAMPLE_MAX_STA_CONN,
.authmode = WIFI_AUTH_WPA_WPA2_PSK
},
};
if (strlen(EXAMPLE_ESP_WIFI_PASS) == 0) {
wifi_config.ap.authmode = WIFI_AUTH_OPEN;
}
ESP_ERROR_CHECK(esp_wifi_set_mode(WIFI_MODE_AP));
ESP_ERROR_CHECK(esp_wifi_set_config(ESP_IF_WIFI_AP, &wifi_config));
ESP_ERROR_CHECK(esp_wifi_start());
ESP_LOGI(TAG, "wifi_init_softap finished. SSID:%s password:%s",
EXAMPLE_ESP_WIFI_SSID, EXAMPLE_ESP_WIFI_PASS);
}
void app_main()
{
ESP_ERROR_CHECK(nvs_flash_init());
ESP_LOGI(TAG, "ESP_WIFI_MODE_AP");
wifi_init_softap();
}
You have to run idf.py menuconfig and set the SSID and password values.
Password´s under 8 characters gets a Guru-Meditation ERR if the
wifi_config.ap.authmode = WIFI_AUTH_WEP or,
wifi_config.ap.authmode = WIFI_AUTH_WPA_PSK or,
wifi_config.ap.authmode = WIFI_AUTH_WPA2_PSK . Other authmodes not yet testet.
To provid this Error, make sure your pw has more then 7 characters or/and set
the If-Condition after the wifi_config to:
if (strlen(EXAMPLE_ESP_WIFI_PASS) < 8) {
wifi_config.ap.authmode = WIFI_AUTH_OPEN;
ESP_LOGI(TAG," pw-lenght under 8 charcters. Set WIFI_AUTH_OPEN");
}
Your WiFi is not protectet but your µC not crashes.

Getting the stack pointer content using Intel's PinTool

Using objdump utility, we are able to retrieved the relative address of a variable for example consider a simple C program:
Source-code:
#include<stdio.h>
void do_stuff(int my_arg){
int my_local=my_arg+2;
int i;
for(i=0;i<my_local;i++)
printf("i=%d\n",i);
}
int main(){
do_stuff(2);
return 0;
}
Compile with gcc :
$ gcc -g example.c -o example
Run objdump utility with dwarf flag for ELF information.
$objdump --dwarf=info example
Output:
Contents of the .debug_info section:
Compilation Unit # offset 0x0:
Length: 0xd3 (32-bit)
Version: 4
Abbrev Offset: 0x0
Pointer Size: 8
<0><b>: Abbrev Number: 1 (DW_TAG_compile_unit)
<c> DW_AT_producer : (indirect string, offset: 0x0): GNU C 4.8.4 -mtune=generic -march=x86-64 -g -fstack-protector
<10> DW_AT_language : 1 (ANSI C)
<11> DW_AT_name : (indirect string, offset: 0xcd): sample1.c
<15> DW_AT_comp_dir : (indirect string, offset: 0x7e): /home/bernard/PhD/TEJAS/tejas_installation_kit/Tejas-Simulator/Tejas/benchmark
<19> DW_AT_low_pc : 0x40052d
<21> DW_AT_high_pc : 0x54
<29> DW_AT_stmt_list : 0x0
<1><2d>: Abbrev Number: 2 (DW_TAG_base_type)
<2e> DW_AT_byte_size : 8
<2f> DW_AT_encoding : 7 (unsigned)
<30> DW_AT_name : (indirect string, offset: 0x47): long unsigned int
<1><34>: Abbrev Number: 2 (DW_TAG_base_type)
<35> DW_AT_byte_size : 1
<36> DW_AT_encoding : 8 (unsigned char)
<37> DW_AT_name : (indirect string, offset: 0x62): unsigned char
<1><3b>: Abbrev Number: 2 (DW_TAG_base_type)
<3c> DW_AT_byte_size : 2
<3d> DW_AT_encoding : 7 (unsigned)
<3e> DW_AT_name : (indirect string, offset: 0xde): short unsigned int
<1><42>: Abbrev Number: 2 (DW_TAG_base_type)
<43> DW_AT_byte_size : 4
<44> DW_AT_encoding : 7 (unsigned)
<45> DW_AT_name : (indirect string, offset: 0x4c): unsigned int
<1><49>: Abbrev Number: 2 (DW_TAG_base_type)
<4a> DW_AT_byte_size : 1
<4b> DW_AT_encoding : 6 (signed char)
<4c> DW_AT_name : (indirect string, offset: 0x64): signed char
<1><50>: Abbrev Number: 2 (DW_TAG_base_type)
<51> DW_AT_byte_size : 2
<52> DW_AT_encoding : 5 (signed)
<53> DW_AT_name : (indirect string, offset: 0xf1): short int
<1><57>: Abbrev Number: 3 (DW_TAG_base_type)
<58> DW_AT_byte_size : 4
<59> DW_AT_encoding : 5 (signed)
<5a> DW_AT_name : int
<1><5e>: Abbrev Number: 2 (DW_TAG_base_type)
<5f> DW_AT_byte_size : 8
<60> DW_AT_encoding : 5 (signed)
<61> DW_AT_name : (indirect string, offset: 0x75): long int
<1><65>: Abbrev Number: 2 (DW_TAG_base_type)
<66> DW_AT_byte_size : 8
<67> DW_AT_encoding : 7 (unsigned)
<68> DW_AT_name : (indirect string, offset: 0xfb): sizetype
<1><6c>: Abbrev Number: 2 (DW_TAG_base_type)
<6d> DW_AT_byte_size : 1
<6e> DW_AT_encoding : 6 (signed char)
<6f> DW_AT_name : (indirect string, offset: 0x6b): char
<1><73>: Abbrev Number: 4 (DW_TAG_subprogram)
<74> DW_AT_external : 1
<74> DW_AT_name : (indirect string, offset: 0x59): do_stuff
<78> DW_AT_decl_file : 1
<79> DW_AT_decl_line : 2
<7a> DW_AT_prototyped : 1
<7a> DW_AT_low_pc : 0x40052d
<82> DW_AT_high_pc : 0x3f
<8a> DW_AT_frame_base : 1 byte block: 9c (DW_OP_call_frame_cfa)
<8c> DW_AT_GNU_all_tail_call_sites: 1
<8c> DW_AT_sibling : <0xb9>
<2><90>: Abbrev Number: 5 (DW_TAG_formal_parameter)
<91> DW_AT_name : (indirect string, offset: 0xd7): my_arg
<95> DW_AT_decl_file : 1
<96> DW_AT_decl_line : 2
<97> DW_AT_type : <0x57>
<9b> DW_AT_location : 2 byte block: 91 5c (DW_OP_fbreg: -36)
<2><9e>: Abbrev Number: 6 (DW_TAG_variable)
<9f> DW_AT_name : (indirect string, offset: 0x3e): my_local
<a3> DW_AT_decl_file : 1
<a4> DW_AT_decl_line : 3
<a5> DW_AT_type : <0x57>
<a9> DW_AT_location : 2 byte block: 91 6c (DW_OP_fbreg: -20)
<2><ac>: Abbrev Number: 7 (DW_TAG_variable)
<ad> DW_AT_name : i
<af> DW_AT_decl_file : 1
<b0> DW_AT_decl_line : 4
<b1> DW_AT_type : <0x57>
<b5> DW_AT_location : 2 byte block: 91 68 (DW_OP_fbreg: -24)
<2><b8>: Abbrev Number: 0
<1><b9>: Abbrev Number: 8 (DW_TAG_subprogram)
<ba> DW_AT_external : 1
<ba> DW_AT_name : (indirect string, offset: 0x70): main
<be> DW_AT_decl_file : 1
<bf> DW_AT_decl_line : 9
<c0> DW_AT_type : <0x57>
<c4> DW_AT_low_pc : 0x40056c
<cc> DW_AT_high_pc : 0x15
<d4> DW_AT_frame_base : 1 byte block: 9c (DW_OP_call_frame_cfa)
<d6> DW_AT_GNU_all_tail_call_sites: 1
<1><d6>: Abbrev Number: 0
I want to do as follows:-
I want to retrieved the address of a variable , say my_local. First I will look into DW_TAG_Variable, then DW_AT_name, DW_AT_location which was given by base register at function -20 from the top.
Question:
How to know the content of base register at run time.
Can we implement it using PinTool.
Question in broader sense:
I want variable my_local map to which address in memory given information from dwarf and Pintool.
Thanks in Advance.
You should be able to use Pin's SafeCopy function to access app memory and copy it into pintool memory.
But as noted in the comments, it's not always possible to know where variable values are stored reliably so keep this in mind.

Cannot parse Width/Height in AVC SPS

Here is the information which I have parsed out of an avcC atom in an mp4 container
The avc extradata Conforms with ISO/IEC 14496-15:2004(E) 5.2.4.1.1
> 0x01 0x42 0x00 0x1E 0xFF 0xE1 0x00 0x0E
Configuration Version: 1 u(8)<br>
AVCProfileIndication: 66 u(8)<br>
profile_compatability: 0 u(8)<br>
AVCLevelIndication: 30 u(8)<br>
bit(6) reserved = '111111' b <br>
unsigned int (2) lengthSizeMinusOne = '11' <br>
bit(3) reseved = '111' <br>
unsigned int (5) numOfSequenceParameterSets = 1 <br>
unsigned int (16) sequenceParameterSetLength = 14 <br>
SPS
> 0x67 0x42 0x00 0x1E 0x8D 0x68 0x6E 0x03 0xDA 0x6A 0x0C 0x02 0x0C 0x04 <br>
avC data Continued
> 0x01 0x00 0x04 <br>
unsigned int (8) numOfPictureParameterSets: 1 <br>
unsigned int (16) pictureParameterSetLength: 4 <br>
PPS <br>
>0x68 0xCE 0x74 0xC8
The contents of the SPS appears to give incorrect results regarding pic_width_in_mbs_minus1 (5) and I do not believe there are any emulation_3_byte preventions. Am I missing something obvious? I am parsing the SPS according to ISO/IEC 14496-10:2004(E) which is the same SPS parsing information found here.
Image is 96x16 (why?)
Sequence Parameter Set
profile_idc 66
constraint_set0_flag 0
constraint_set1_flag 0
constraint_set2_flag 0
constraint_set3_flag 0
level_idc 30
seq_parameter_set_id 0
// ...
num_ref_frames 1
gaps_in_frame_num_value_allowed_flag 0
pic_width_in_mbs_minus1 5
pic_height_in_map_units_minus1 0
frame_mbs_only_flag 1
direct_8x8_inference_flag 1
frame_cropping_flag 0
vui_parameters_present_flag 0
// ...
Picture Parameter Set
pic_parameter_set_id 0
seq_parameter_set_id 0
entropy_coding_mode_flag 0
num_slice_groups_minus1 0
// ...

Is extra space allocated for variant records?

I'm working with the variant record below. The variable instance is Kro_Combi. SizeOf(Kro_Combi) reports 7812 bytes. SizeOf(Kro_Combi.data) reports 7810 bytes.
The sum of the SizeOf of all the other data structures composing the "non-directmode" case of the variant record also adds to 7810 bytes.
Why is there a two byte difference? I would like to have the two variant exactly overlay each other.
TKro_Combi = record
case directmode:boolean of
true : (
data : array[0..7809] of byte
);
false : (
Combi_Name : array[0..23] of char; //24
Gap1 : array[0..63] of byte; // 24-87 (64)
Ins_Effect_Group : array[1..12] of TIns_Effect_Params; //74 each, (Ins_Effect_Data=9 bytes) 74*12 = 888
Mast_Effect_Params : array[0..229] of byte; // 976-1205 : 230 bytes
Vect_Aud__Drum_Params : array[0..97] of byte; //1206-1303 : 98 bytes
Karma_Common : array[0..509] of byte; //1304-1813 : 510 bytes
Karma_Module : array[0..3] of TKarma_Module; //1814-2557 : 744 bytes each Total span 1814 - 4789 = 2976 bytes total
Common_Params : array[0..11] of byte; //4790-4801 = 12 bytes
Timbre_Group : array[1..16] of TTimbre_Params; ) // 4802 -4989 = 188 bytes each, 16 Timbres, 4802-7809 = 3008 bytes total for all
end;
First of all, there needs to be space for the directmode field. If you really want the record to have size 7810 bytes then you should remove that field. The other byte will be due to internal alignment and padding of the false part of the variant record. I can't yet quite work out where it comes from. No matter, you simply want to use a packed record to avoid any padding bytes.
TKro_Combi = packed record
case boolean of
true : (
data : array[0..7809] of byte
);
false : (
Combi_Name : array[0..23] of char; //24
Gap1 : array[0..63] of byte; // 24-87 (64)
Ins_Effect_Group : array[1..12] of TIns_Effect_Params; //74 each, (Ins_Effect_Data=9 bytes) 74*12 = 888
Mast_Effect_Params : array[0..229] of byte; // 976-1205 : 230 bytes
Vect_Aud__Drum_Params : array[0..97] of byte; //1206-1303 : 98 bytes
Karma_Common : array[0..509] of byte; //1304-1813 : 510 bytes
Karma_Module : array[0..3] of TKarma_Module; //1814-2557 : 744 bytes each Total span 1814 - 4789 = 2976 bytes total
Common_Params : array[0..11] of byte; //4790-4801 = 12 bytes
Timbre_Group : array[1..16] of TTimbre_Params; ) // 4802 -4989 = 188 bytes each, 16 Timbres, 4802-7809 = 3008 bytes total for all
end;

Resources