// File: /workspace/github_cpp_makefile_star2_O3/CDISC2020[P]Projet_satellite_agile/src/communication/comGroundManager.cpp
// Function: Communic_Interne(void*)
void* Communic_Interne(void* args)
{
	QueuingPort channelIn(1, 18003, s); 		// Server
	usleep(500000);
	channelIn.Display();
	usleep(300000);

	while(1)
	{
		channelIn.RecvQueuingMsg(buffer);

		status = (Status*)buffer;

 		/**************[ PM ---IMG---> CGM ]**************/
		// Remplir le tableau avec des photos prises
		if (status->code == 3)		// utilisation d'un type p
		{
			imageName = (PlanFilePath*)buffer;
			string aux(imageName->filepath);
			imageList[ptImageReceived] = aux;
			ptImageReceived = (ptImageReceived + 1)%128;
		}

 		/**************[ PM ---LOG---> CGM ]**************/
		// Plan manager --> Comunication Manager
		// Error identifier and description
		else if(status->code == 4)
		{
			string str(status->description);
			sm.newNotification(status->errorID, str);
		}

		/*************[ FDIR ---MODE---> CGM ]*************/
		// changement mode primary ou backup
		else if(status->code == 6)
		{
			m = (ModeStruct*)buffer;
			mode = m->rpiMode;
		}

		usleep(100);
	}

	return NULL;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x508, %rsp            # imm = 0x508
leaq 0x527d(%rip), %rcx      # 0x92f0
leaq -0x530(%rbp), %rbx
movq %rbx, %rdi
movl $0x1, %esi
movl $0x4653, %edx           # imm = 0x4653
callq 0x2866
movl $0x7a120, %edi          # imm = 0x7A120
callq 0x2370
movq %rbx, %rdi
callq 0x2d88
movl $0x493e0, %edi          # imm = 0x493E0
callq 0x2370
leaq -0x38(%rbp), %r15
leaq 0x52ad(%rip), %r14      # 0x9360
leaq -0x68(%rbp), %r12
movq %rbx, %rdi
movq %r14, %rsi
callq 0x2b68
movq %r14, 0x41f7(%rip)      # 0x82c0
movl 0x5291(%rip), %eax      # 0x9360
cmpl $0x6, %eax
je 0x41ff
cmpl $0x4, %eax
je 0x417e
cmpl $0x3, %eax
jne 0x4212
movq %rbx, %r12
movq %r14, 0x41e4(%rip)      # 0x82d8
movq %r15, %rbx
movq %r15, -0x48(%rbp)
leaq 0x5262(%rip), %r15      # 0x9364
movq %r15, %rdi
callq 0x2130
leaq (%rax,%r14), %rdx
addq $0x4, %rdx
leaq -0x48(%rbp), %r13
movq %r13, %rdi
movq %r15, %rsi
callq 0x3304
movslq 0x51b8(%rip), %rdi      # 0x92e0
shlq $0x5, %rdi
leaq 0x41ad(%rip), %rax      # 0x82e0
addq %rax, %rdi
movq %r13, %rsi
callq 0x2170
movl 0x519c(%rip), %eax      # 0x92e0
leal 0x1(%rax), %ecx
leal 0x80(%rax), %edx
testl %ecx, %ecx
cmovnsl %ecx, %edx
andl $-0x80, %edx
negl %edx
addl %edx, %eax
incl %eax
movl %eax, 0x517f(%rip)      # 0x92e0
movq -0x48(%rbp), %rdi
movq %rbx, %r15
cmpq %rbx, %rdi
je 0x4172
callq 0x2280
movq %r12, %rbx
leaq -0x68(%rbp), %r12
jmp 0x4212
movq %r15, -0x48(%rbp)
leaq 0x51df(%rip), %r13      # 0x9368
movq %r13, %rdi
callq 0x2130
leaq (%rax,%r14), %rdx
addq $0x8, %rdx
leaq -0x48(%rbp), %rdi
movq %r13, %rsi
callq 0x3304
movq 0x4114(%rip), %rax      # 0x82c0
movl 0x4(%rax), %r13d
leaq -0x58(%rbp), %rax
movq %rax, -0x68(%rbp)
movq -0x48(%rbp), %rsi
movq -0x40(%rbp), %rdx
addq %rsi, %rdx
movq %r12, %rdi
callq 0x469e
leaq 0x40ce(%rip), %rdi      # 0x82a0
movl %r13d, %esi
movq %r12, %rdx
callq 0x3128
movq -0x68(%rbp), %rdi
leaq -0x58(%rbp), %rax
cmpq %rax, %rdi
je 0x41ef
callq 0x2280
movq -0x48(%rbp), %rdi
cmpq %r15, %rdi
je 0x4212
callq 0x2280
jmp 0x4212
movq %r14, 0x40ca(%rip)      # 0x82d0
movb 0x5158(%rip), %al       # 0x9364
movb %al, 0x50d6(%rip)       # 0x92e8
movl $0x64, %edi
callq 0x2370
jmp 0x40b7
movq %rax, %r14
movq -0x68(%rbp), %rdi
leaq -0x58(%rbp), %rax
cmpq %rax, %rdi
je 0x4249
callq 0x2280
jmp 0x4249
movq %rax, %r14
movq -0x48(%rbp), %rdi
cmpq %rbx, %rdi
jne 0x4252
jmp 0x425e
movq %rax, %r14
movq -0x48(%rbp), %rdi
cmpq %r15, %rdi
je 0x425e
callq 0x2280
jmp 0x425e
jmp 0x425b
movq %rax, %r14
movq %r14, %rdi
callq 0x2470