// File: /workspace/github_cpp_makefile_star2_O1/bummelbaerchen[P]e3dc/RscpExampleMain.cpp
// Function: createRequestWBData(SRscpFrameBuffer*)
int createRequestWBData(SRscpFrameBuffer * frameBuffer) {
    RscpProtocol protocol;
    SRscpValue rootValue;

    iWBStatus=7;
    
    // The root container is create with the TAG ID 0 which is not used by any device.
    protocol.createContainerValue(&rootValue, 0);
    
    // request Power Meter information
    SRscpValue WBContainer;
    SRscpValue WB2Container;

    // request Wallbox data

    protocol.createContainerValue(&WBContainer, TAG_WB_REQ_DATA) ;
    // add index 0 to select first wallbox
    protocol.appendValue(&WBContainer, TAG_WB_INDEX,0);

    
    protocol.createContainerValue(&WB2Container, TAG_WB_REQ_SET_EXTERN);
    protocol.appendValue(&WB2Container, TAG_WB_EXTERN_DATA_LEN,6);
    protocol.appendValue(&WB2Container, TAG_WB_EXTERN_DATA,WBchar6,iWBLen);

    protocol.appendValue(&WBContainer, WB2Container);
    // free memory of sub-container as it is now copied to rootValue
    protocol.destroyValueData(WB2Container);

    
// append sub-container to root container
    protocol.appendValue(&rootValue, WBContainer);
//    protocol.appendValue(&rootValue, WB2Container);
    // free memory of sub-container as it is now copied to rootValue
    protocol.destroyValueData(WBContainer);
    
    // create buffer frame to send data to the S10
    protocol.createFrameAsBuffer(frameBuffer, rootValue.data, rootValue.length, true); // true to calculate CRC on for transfer
    // the root value object should be destroyed after the data is copied into the frameBuffer and is not needed anymore
    protocol.destroyValueData(rootValue);
    
    return 0;
}

// Assembly:
pushq %r14
pushq %rbx
subq $0x48, %rsp
movq %rdi, %rbx
leaq 0x8(%rsp), %r14
movq %r14, %rdi
callq 0x76c4
movl $0x7, 0x14eaf(%rip)     # 0x177a4
leaq 0x18(%rsp), %rdx
movl $0x0, (%rdx)
leaq 0x10(%rsp), %r9
movb $0xe, (%r9)
leaq 0x2a(%rsp), %r8
movw $0x0, (%r8)
leaq 0x39(%rsp), %rsi
movq %r14, %rdi
xorl %ecx, %ecx
callq 0x80f0
leaq 0x10(%rsp), %rdx
movl $0xe040000, (%rdx)      # imm = 0xE040000
leaq 0x4(%rsp), %r9
movb $0xe, (%r9)
leaq 0x14(%rsp), %r8
movw $0x0, (%r8)
leaq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rsi
xorl %ecx, %ecx
callq 0x80f0
leaq 0x10(%rsp), %rdx
movl $0xe040001, (%rdx)      # imm = 0xE040001
leaq 0x14(%rsp), %rcx
movl $0x0, (%rcx)
leaq 0x4(%rsp), %r8
movw $0x4, (%r8)
leaq 0x7(%rsp), %r9
movb $0x6, (%r9)
leaq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rsi
callq 0x82b2
leaq 0x10(%rsp), %rdx
movl $0xe041010, (%rdx)      # imm = 0xE041010
leaq 0x4(%rsp), %r9
movb $0xe, (%r9)
leaq 0x14(%rsp), %r8
movw $0x0, (%r8)
leaq 0x8(%rsp), %rdi
leaq 0x2a(%rsp), %rsi
xorl %ecx, %ecx
callq 0x80f0
leaq 0x10(%rsp), %rdx
movl $0xe042011, (%rdx)      # imm = 0xE042011
leaq 0x14(%rsp), %rcx
movl $0x6, (%rcx)
leaq 0x4(%rsp), %r8
movw $0x4, (%r8)
leaq 0x7(%rsp), %r9
movb $0x6, (%r9)
leaq 0x8(%rsp), %rdi
leaq 0x2a(%rsp), %rsi
callq 0x82b2
leaq 0x10(%rsp), %rdx
movl $0xe042010, (%rdx)      # imm = 0xE042010
leaq 0x14(%rsp), %r9
movb $0x10, (%r9)
leaq 0x14d98(%rip), %rcx     # 0x177a8
leaq 0x10841(%rip), %r8      # 0x13258
leaq 0x8(%rsp), %rdi
leaq 0x2a(%rsp), %rsi
callq 0x82b2
leaq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rsi
leaq 0x2a(%rsp), %rdx
callq 0x7464
leaq 0x8(%rsp), %rdi
leaq 0x2a(%rsp), %rsi
callq 0x85d0
leaq 0x8(%rsp), %rdi
leaq 0x39(%rsp), %rsi
leaq 0x18(%rsp), %rdx
callq 0x7464
leaq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rsi
callq 0x85d0
movq 0x40(%rsp), %rdx
movzwl 0x3e(%rsp), %ecx
leaq 0x8(%rsp), %rdi
movq %rbx, %rsi
movl $0x1, %r8d
callq 0x77ac
leaq 0x8(%rsp), %rdi
leaq 0x39(%rsp), %rsi
callq 0x85d0
leaq 0x8(%rsp), %rdi
callq 0x76d0
xorl %eax, %eax
addq $0x48, %rsp
popq %rbx
popq %r14
retq
jmp 0x2ab8
jmp 0x2ab8
jmp 0x2ab8
jmp 0x2ab8
jmp 0x2ab8
jmp 0x2ab8
movq %rax, %rbx
leaq 0x8(%rsp), %rdi
callq 0x76d0
movq %rbx, %rdi
callq 0x2290