// File: /workspace/github_cpp_makefile_star2_O1/pehublove[P]GPS-neo7n-forBaiduMap/test.cpp
// Function: main
int main(int argc, char **argv)
{
	int fd;
	int nread,i,n =0,datalen=255, len = 0;
	char testbuff[]="Hello\r\n";
	char readbuff[256];
	
	fd=serialport();
	printf("fd=%d\n",fd);
	//尝试先写内容
	nread=write(fd,testbuff,datalen);
	if(nread==-1)
	{
		printf("write bad\n");
	}
	else{
		printf("the test is ok!\n");
	}	
	//循环读取串口并输出
	while(1)
	{
		//printf("enter the while loop\n");
		bzero(readbuff, sizeof(readbuff));
		datalen=serial_read(fd,readbuff,255);
		if(datalen > 0)
		{
			cout << datalen << endl;
			string parseStr = readbuff;
			cout << parseStr << endl;
			vector<string> every;
			split(every, parseStr, "\n");
			vector<string>::iterator it = every.begin();
			for(;it != every.end();it++)
			{
			if(it->find("GPRMC") != string::npos)
			{
				vector<string> vecGps;
				vecGps.reserve(15);
				split(vecGps, *it, ",");
				if(vecGps.at(2) == "A")
				{
					cout << "valid data" << endl;
					cout << "longitude: " << vecGps.at(5) << endl;
					cout << "latitude: " << vecGps.at(3) << endl;
					double lon = stod(vecGps.at(5));
					double lat = stod(vecGps.at(3));
					int tempF = (int)lon / 100;
					double point = (lon - tempF * 100)/60;
					double longitude = tempF + point;

					int tempF1 = (int)lat / 100;
					double point1 = (lat - tempF1 * 100)/60;
					double latitude = tempF1 + point1;

					double latbd,lonbd;
					GpsBaidu::gps2bd(latitude, longitude, latbd, lonbd);
					cout << endl;
					cout << "Baidu longitude: " << lonbd << endl;
					cout << "Baidu latitude: " << latbd << endl;
				}
			}
			}

		}
	}
	return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x188, %rsp            # imm = 0x188
callq 0x258f
movl %eax, %ebx
leaq 0x19cc(%rip), %rdi      # 0x40e6
movl %eax, %esi
xorl %eax, %eax
callq 0x2050
leaq 0x19b4(%rip), %rsi      # 0x40de
movl $0xff, %edx
movl %ebx, -0x64(%rbp)
movl %ebx, %edi
callq 0x2090
cmpl $-0x1, %eax
leaq 0x1aa6(%rip), %rax      # 0x41e9
leaq 0x1a8f(%rip), %rdi      # 0x41d9
cmoveq %rax, %rdi
callq 0x2270
leaq -0x50(%rbp), %r12
leaq -0x1b0(%rbp), %rbx
leaq 0x1988(%rip), %r13      # 0x40ed
movl $0x100, %edx            # imm = 0x100
movq %rbx, %rdi
xorl %esi, %esi
callq 0x20d0
movl $0xff, %edx
movl -0x64(%rbp), %edi
movq %rbx, %rsi
callq 0x2220
testl %eax, %eax
jle 0x2765
movl %eax, %ecx
andl $0x7fffffff, %ecx       # imm = 0x7FFFFFFF
movb $0x0, -0x1b0(%rbp,%rcx)
movq 0x3839(%rip), %r15      # 0x5fd8
movq %r15, %rdi
movl %eax, %esi
callq 0x2290
movq %rax, %r14
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x21a0
movsbl %al, %esi
movq %r14, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x2110
leaq -0x78(%rbp), %rax
movq %rax, -0x88(%rbp)
movq %rbx, %rdi
callq 0x20b0
leaq (%rax,%rbp), %rdx
addq $-0x1b0, %rdx           # imm = 0xFE50
leaq -0x88(%rbp), %rdi
movq %rbx, %rsi
movq %r15, %rbx
callq 0x2f42
movq -0x88(%rbp), %rsi
movq -0x80(%rbp), %rdx
movq %r15, %rdi
callq 0x2200
movq %rax, %r14
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x21a0
movsbl %al, %esi
movq %r14, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x2110
xorpd %xmm0, %xmm0
movapd %xmm0, -0xa0(%rbp)
movq $0x0, -0x90(%rbp)
movq %r12, -0x60(%rbp)
leaq -0x60(%rbp), %r15
movq %r15, %rdi
leaq 0x187b(%rip), %rsi      # 0x40e4
leaq 0x1875(%rip), %rdx      # 0x40e5
callq 0x2f42
leaq -0xa0(%rbp), %rdi
leaq -0x88(%rbp), %rsi
movq %r15, %rdx
callq 0x25c5
movq -0x60(%rbp), %rdi
cmpq %r12, %rdi
je 0x28a0
movq -0x50(%rbp), %rsi
incq %rsi
callq 0x21c0
movq -0xa0(%rbp), %r14
cmpq -0x98(%rbp), %r14
je 0x2ca4
movl $0x5, %ecx
movq %r14, %rdi
movq %r13, %rsi
xorl %edx, %edx
callq 0x22a0
cmpq $-0x1, %rax
je 0x2c9b
xorpd %xmm0, %xmm0
movapd %xmm0, -0x40(%rbp)
movq $0x0, -0x30(%rbp)
movl $0xf, %esi
leaq -0x40(%rbp), %rdi
callq 0x2de6
movq %r12, -0x60(%rbp)
movq %r15, %rdi
leaq 0x17f6(%rip), %rsi      # 0x40f3
leaq 0x17f0(%rip), %rdx      # 0x40f4
callq 0x2f42
leaq -0x40(%rbp), %rdi
movq %r14, %rsi
movq %r15, %rdx
callq 0x25c5
movq -0x60(%rbp), %rdi
cmpq %r12, %rdi
je 0x292d
movq -0x50(%rbp), %rsi
incq %rsi
callq 0x21c0
movq -0x40(%rbp), %rdi
movq -0x38(%rbp), %rdx
subq %rdi, %rdx
sarq $0x5, %rdx
cmpq $0x2, %rdx
jbe 0x2cd8
addq $0x40, %rdi
leaq 0x17a4(%rip), %rsi      # 0x40f5
callq 0x2080
testl %eax, %eax
jne 0x2c92
movl $0xa, %edx
movq %rbx, %rdi
leaq 0x178a(%rip), %rsi      # 0x40f7
callq 0x2200
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x21a0
movsbl %al, %esi
movq %rbx, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x2110
movl $0xb, %edx
movq %rbx, %rdi
leaq 0x1760(%rip), %rsi      # 0x4108
callq 0x2200
movq -0x40(%rbp), %rax
movq -0x38(%rbp), %rdx
subq %rax, %rdx
sarq $0x5, %rdx
cmpq $0x6, %rdx
jb 0x2d1d
movq 0xa0(%rax), %rsi
movq 0xa8(%rax), %rdx
movq %rbx, %rdi
callq 0x2200
movq %rax, %r12
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r12, %rdi
movl $0xa, %esi
callq 0x21a0
movsbl %al, %esi
movq %r12, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x2110
movl $0xa, %edx
movq %rbx, %rdi
leaq 0x1705(%rip), %rsi      # 0x411a
callq 0x2200
movq -0x40(%rbp), %rax
movq -0x38(%rbp), %rdx
subq %rax, %rdx
sarq $0x5, %rdx
cmpq $0x4, %rdx
jb 0x2d24
movq 0x60(%rax), %rsi
movq 0x68(%rax), %rdx
movq %rbx, %rdi
callq 0x2200
movq %rax, %r12
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r12, %rdi
movl $0xa, %esi
callq 0x21a0
movsbl %al, %esi
movq %r12, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x2110
movq -0x40(%rbp), %rax
movq -0x38(%rbp), %rdx
subq %rax, %rdx
sarq $0x5, %rdx
cmpq $0x5, %rdx
jbe 0x2cf7
movq 0xa0(%rax), %rbx
callq 0x2040
movq %rax, %r12
movl (%rax), %r13d
movl $0x0, (%rax)
movq %rbx, %rdi
movq %r15, %rsi
callq 0x2140
cmpq %rbx, -0x60(%rbp)
je 0x2ceb
movl (%r12), %eax
testl %eax, %eax
je 0x2ac5
cmpl $0x22, %eax
jne 0x2ac9
jmp 0x2d37
movl %r13d, (%r12)
movq -0x40(%rbp), %rax
movq -0x38(%rbp), %rdx
subq %rax, %rdx
sarq $0x5, %rdx
cmpq $0x3, %rdx
jbe 0x2d0a
movsd %xmm0, -0xa8(%rbp)
movq 0x60(%rax), %rbx
movl (%r12), %r13d
movl $0x0, (%r12)
movq %rbx, %rdi
leaq -0x60(%rbp), %rsi
callq 0x2140
cmpq %rbx, -0x60(%rbp)
je 0x2cdf
movl (%r12), %eax
testl %eax, %eax
je 0x2b29
cmpl $0x22, %eax
movq 0x34b6(%rip), %rbx      # 0x5fd8
jne 0x2b34
jmp 0x2d43
movl %r13d, (%r12)
movq 0x34a4(%rip), %rbx      # 0x5fd8
movsd -0xa8(%rbp), %xmm2
cvttsd2si %xmm2, %eax
cltq
imulq $0x51eb851f, %rax, %rax # imm = 0x51EB851F
movq %rax, %rcx
shrq $0x3f, %rcx
sarq $0x25, %rax
addl %ecx, %eax
imull $0x64, %eax, %ecx
cvtsi2sd %ecx, %xmm1
subsd %xmm1, %xmm2
movsd 0x149f(%rip), %xmm3     # 0x4008
divsd %xmm3, %xmm2
xorps %xmm1, %xmm1
cvtsi2sd %eax, %xmm1
addsd %xmm2, %xmm1
cvttsd2si %xmm0, %eax
cltq
imulq $0x51eb851f, %rax, %rax # imm = 0x51EB851F
movq %rax, %rcx
shrq $0x3f, %rcx
sarq $0x25, %rax
addl %ecx, %eax
imull $0x64, %eax, %ecx
xorps %xmm2, %xmm2
cvtsi2sd %ecx, %xmm2
subsd %xmm2, %xmm0
divsd %xmm3, %xmm0
xorps %xmm2, %xmm2
cvtsi2sd %eax, %xmm2
addsd %xmm0, %xmm2
movapd %xmm2, %xmm0
leaq -0x60(%rbp), %rdi
leaq -0xb0(%rbp), %rsi
callq 0x380a
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x21a0
movsbl %al, %esi
movq %rbx, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x2110
movl $0x11, %edx
movq %rbx, %rdi
leaq 0x1509(%rip), %rsi      # 0x4102
callq 0x2200
movsd -0xb0(%rbp), %xmm0
movq %rbx, %rdi
callq 0x2280
movq %rax, %r12
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r12, %rdi
movl $0xa, %esi
callq 0x21a0
movsbl %al, %esi
movq %r12, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x2110
movl $0x10, %edx
movq %rbx, %rdi
leaq 0x14cd(%rip), %rsi      # 0x4114
callq 0x2200
movsd -0x60(%rbp), %xmm0
movq %rbx, %rdi
callq 0x2280
movq %rax, %r12
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r12, %rdi
movl $0xa, %esi
callq 0x21a0
movsbl %al, %esi
movq %r12, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x2110
leaq -0x50(%rbp), %r12
leaq -0x60(%rbp), %r15
leaq 0x145b(%rip), %r13      # 0x40ed
leaq -0x40(%rbp), %rdi
callq 0x2ed8
addq $0x20, %r14
jmp 0x28a7
leaq -0xa0(%rbp), %rdi
callq 0x2ed8
movq -0x88(%rbp), %rdi
leaq -0x78(%rbp), %rax
cmpq %rax, %rdi
je 0x2ccc
movq -0x78(%rbp), %rsi
incq %rsi
callq 0x21c0
leaq -0x1b0(%rbp), %rbx
jmp 0x2765
movl $0x2, %esi
jmp 0x2d29
leaq 0x143f(%rip), %rdi      # 0x4125
callq 0x2100
leaq 0x1433(%rip), %rdi      # 0x4125
callq 0x2100
leaq 0x1480(%rip), %rdi      # 0x417e
movl $0x5, %esi
xorl %eax, %eax
callq 0x2240
leaq 0x146d(%rip), %rdi      # 0x417e
movl $0x3, %esi
xorl %eax, %eax
callq 0x2240
movl $0x5, %esi
jmp 0x2d29
movl $0x3, %esi
leaq 0x144e(%rip), %rdi      # 0x417e
xorl %eax, %eax
callq 0x2240
leaq 0x13e7(%rip), %rdi      # 0x4125
callq 0x2230
leaq 0x13db(%rip), %rdi      # 0x4125
callq 0x2230
movq %rax, %rbx
movq -0x60(%rbp), %rdi
cmpq %r12, %rdi
je 0x2db5
movq -0x50(%rbp), %rsi
incq %rsi
callq 0x21c0
jmp 0x2db5
movq %rax, %rbx
jmp 0x2db5
movq %rax, %rbx
jmp 0x2dc1
jmp 0x2da9
jmp 0x2da9
jmp 0x2d79
movq %rax, %rbx
cmpl $0x0, (%r12)
jne 0x2dac
movl %r13d, (%r12)
jmp 0x2dac
jmp 0x2da9
movq %rax, %rbx
movq -0x60(%rbp), %rdi
cmpq %r12, %rdi
je 0x2dac
movq -0x50(%rbp), %rsi
incq %rsi
callq 0x21c0
jmp 0x2dac
jmp 0x2da9
jmp 0x2da9
movq %rax, %rbx
leaq -0x40(%rbp), %rdi
callq 0x2ed8
leaq -0xa0(%rbp), %rdi
callq 0x2ed8
movq -0x88(%rbp), %rdi
leaq -0x78(%rbp), %rax
cmpq %rax, %rdi
je 0x2ddd
movq -0x78(%rbp), %rsi
incq %rsi
callq 0x21c0
movq %rbx, %rdi
callq 0x22b0
nop