// File: /workspace/github_cpp_makefile_star2_O3/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 0x19da(%rip), %rdi      # 0x40e6
movl %eax, %esi
xorl %eax, %eax
callq 0x2050
leaq 0x19c2(%rip), %rsi      # 0x40de
movl $0xff, %edx
movl %ebx, -0x64(%rbp)
movl %ebx, %edi
callq 0x2090
cmpl $-0x1, %eax
leaq 0x1ab4(%rip), %rax      # 0x41e9
leaq 0x1a9d(%rip), %rdi      # 0x41d9
cmoveq %rax, %rdi
callq 0x2270
leaq -0x50(%rbp), %r15
leaq -0x1b0(%rbp), %rbx
movq 0x3881(%rip), %r13      # 0x5fd8
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 0x2757
movl %eax, %ecx
andl $0x7fffffff, %ecx       # imm = 0x7FFFFFFF
movb $0x0, -0x1b0(%rbp,%rcx)
movq %r13, %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
callq 0x2f42
movq -0x88(%rbp), %rsi
movq -0x80(%rbp), %rdx
movq %r13, %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 %r15, -0x60(%rbp)
leaq -0x60(%rbp), %rbx
movq %rbx, %rdi
leaq 0x1893(%rip), %rsi      # 0x40e4
leaq 0x188d(%rip), %rdx      # 0x40e5
callq 0x2f42
leaq -0xa0(%rbp), %rdi
leaq -0x88(%rbp), %rsi
movq %rbx, %rdx
callq 0x25c5
movq -0x60(%rbp), %rdi
cmpq %r15, %rdi
je 0x2888
movq -0x50(%rbp), %rsi
incq %rsi
callq 0x21c0
movq -0xa0(%rbp), %r14
cmpq -0x98(%rbp), %r14
je 0x2c92
movl $0x5, %ecx
movq %r14, %rdi
leaq 0x1842(%rip), %rsi      # 0x40ed
xorl %edx, %edx
callq 0x22a0
cmpq $-0x1, %rax
je 0x2c89
xorpd %xmm0, %xmm0
movapd %xmm0, -0x40(%rbp)
movq $0x0, -0x30(%rbp)
movl $0xf, %esi
leaq -0x40(%rbp), %rdi
callq 0x2de2
movq %r15, -0x60(%rbp)
movq %rbx, %rdi
leaq 0x180a(%rip), %rsi      # 0x40f3
leaq 0x1804(%rip), %rdx      # 0x40f4
callq 0x2f42
leaq -0x40(%rbp), %rdi
movq %r14, %rsi
movq %rbx, %rdx
callq 0x25c5
movq -0x60(%rbp), %rdi
cmpq %r15, %rdi
je 0x2919
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 0x2cc6
addq $0x40, %rdi
leaq 0x17b8(%rip), %rsi      # 0x40f5
callq 0x2080
testl %eax, %eax
jne 0x2c80
movl $0xa, %edx
movq %r13, %rdi
leaq 0x179e(%rip), %rsi      # 0x40f7
callq 0x2200
movq (%r13), %rax
movq -0x18(%rax), %rdi
addq %r13, %rdi
movl $0xa, %esi
callq 0x21a0
movsbl %al, %esi
movq %r13, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x2110
movl $0xb, %edx
movq %r13, %rdi
leaq 0x1773(%rip), %rsi      # 0x4108
callq 0x2200
movq -0x40(%rbp), %rax
movq -0x38(%rbp), %rdx
subq %rax, %rdx
sarq $0x5, %rdx
cmpq $0x6, %rdx
jb 0x2d0b
movq 0xa0(%rax), %rsi
movq 0xa8(%rax), %rdx
movq %r13, %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 %r13, %rdi
leaq 0x1718(%rip), %rsi      # 0x411a
callq 0x2200
movq -0x40(%rbp), %rax
movq -0x38(%rbp), %rdx
subq %rax, %rdx
sarq $0x5, %rdx
cmpq $0x4, %rdx
jb 0x2d12
movq 0x60(%rax), %rsi
movq 0x68(%rax), %rdx
movq %r13, %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 0x2ce5
movq %rbx, %r15
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 0x2cd9
movl (%r12), %r15d
testl %r15d, %r15d
je 0x2ab7
cmpl $0x22, %r15d
jne 0x2abe
jmp 0x2d25
movl %r13d, (%r12)
movl %r13d, %r15d
movq -0x40(%rbp), %rax
movq -0x38(%rbp), %rdx
subq %rax, %rdx
sarq $0x5, %rdx
cmpq $0x3, %rdx
jbe 0x2cf8
movsd %xmm0, -0xa8(%rbp)
movq 0x60(%rax), %rbx
movl $0x0, (%r12)
movq %rbx, %rdi
leaq -0x60(%rbp), %rsi
callq 0x2140
cmpq %rbx, -0x60(%rbp)
je 0x2ccd
movl (%r12), %eax
testl %eax, %eax
je 0x2b1e
cmpl $0x22, %eax
movq 0x34c5(%rip), %r13      # 0x5fd8
leaq -0x60(%rbp), %rbx
jne 0x2b2d
jmp 0x2d31
movl %r15d, (%r12)
movq 0x34af(%rip), %r13      # 0x5fd8
leaq -0x60(%rbp), %rbx
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 0x14a6(%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
movq %rbx, %rdi
leaq -0xb0(%rbp), %rsi
callq 0x37be
movq (%r13), %rax
movq -0x18(%rax), %rdi
addq %r13, %rdi
movl $0xa, %esi
callq 0x21a0
movsbl %al, %esi
movq %r13, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x2110
movl $0x11, %edx
movq %r13, %rdi
leaq 0x1510(%rip), %rsi      # 0x4102
callq 0x2200
movsd -0xb0(%rbp), %xmm0
movq %r13, %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 %r13, %rdi
leaq 0x14d4(%rip), %rsi      # 0x4114
callq 0x2200
movsd -0x60(%rbp), %xmm0
movq %r13, %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), %r15
leaq -0x40(%rbp), %rdi
callq 0x2ed4
addq $0x20, %r14
jmp 0x288f
leaq -0xa0(%rbp), %rdi
callq 0x2ed4
movq -0x88(%rbp), %rdi
leaq -0x78(%rbp), %rax
cmpq %rax, %rdi
je 0x2cba
movq -0x78(%rbp), %rsi
incq %rsi
callq 0x21c0
leaq -0x1b0(%rbp), %rbx
jmp 0x2757
movl $0x2, %esi
jmp 0x2d17
leaq 0x1451(%rip), %rdi      # 0x4125
callq 0x2100
leaq 0x1445(%rip), %rdi      # 0x4125
callq 0x2100
leaq 0x1492(%rip), %rdi      # 0x417e
movl $0x5, %esi
xorl %eax, %eax
callq 0x2240
leaq 0x147f(%rip), %rdi      # 0x417e
movl $0x3, %esi
xorl %eax, %eax
callq 0x2240
movl $0x5, %esi
jmp 0x2d17
movl $0x3, %esi
leaq 0x1460(%rip), %rdi      # 0x417e
xorl %eax, %eax
callq 0x2240
leaq 0x13f9(%rip), %rdi      # 0x4125
callq 0x2230
leaq 0x13ed(%rip), %rdi      # 0x4125
callq 0x2230
movq %rax, %rbx
movq -0x60(%rbp), %rdi
cmpq %r15, %rdi
je 0x2db1
movq -0x50(%rbp), %rsi
incq %rsi
callq 0x21c0
jmp 0x2db1
movq %rax, %rbx
jmp 0x2db1
movq %rax, %rbx
jmp 0x2dbd
jmp 0x2da5
jmp 0x2da5
movq %rax, %rbx
cmpl $0x0, (%r12)
jne 0x2da8
movl %r13d, (%r12)
jmp 0x2da8
movq %rax, %rbx
cmpl $0x0, (%r12)
jne 0x2da8
movl %r15d, (%r12)
jmp 0x2da8
jmp 0x2da5
movq %rax, %rbx
movq -0x60(%rbp), %rdi
cmpq %r15, %rdi
je 0x2da8
movq -0x50(%rbp), %rsi
incq %rsi
callq 0x21c0
jmp 0x2da8
jmp 0x2da5
jmp 0x2da5
movq %rax, %rbx
leaq -0x40(%rbp), %rdi
callq 0x2ed4
leaq -0xa0(%rbp), %rdi
callq 0x2ed4
movq -0x88(%rbp), %rdi
leaq -0x78(%rbp), %rax
cmpq %rax, %rdi
je 0x2dd9
movq -0x78(%rbp), %rsi
incq %rsi
callq 0x21c0
movq %rbx, %rdi
callq 0x22b0
nop