// File: 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
subq $0x310, %rsp            # imm = 0x310
movl $0x0, -0x4(%rbp)
movl %edi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl $0x0, -0x20(%rbp)
movl $0xff, -0x24(%rbp)
movl $0x0, -0x28(%rbp)
movq 0x27bb(%rip), %rax      # 0x50e0
movq %rax, -0x30(%rbp)
callq 0x2730
movl %eax, -0x14(%rbp)
movl -0x14(%rbp), %esi
leaq 0x27ad(%rip), %rdi      # 0x50e8
movb $0x0, %al
callq 0x2040
movl -0x14(%rbp), %edi
leaq -0x30(%rbp), %rsi
movslq -0x24(%rbp), %rdx
callq 0x20a0
movl %eax, -0x18(%rbp)
cmpl $-0x1, -0x18(%rbp)
jne 0x296b
leaq 0x278d(%rip), %rdi      # 0x50ef
movb $0x0, %al
callq 0x2040
jmp 0x2979
leaq 0x2788(%rip), %rdi      # 0x50fa
movb $0x0, %al
callq 0x2040
jmp 0x297b
leaq -0x130(%rbp), %rdi
xorl %esi, %esi
movl $0x100, %edx            # imm = 0x100
callq 0x2100
movl -0x14(%rbp), %edi
leaq -0x130(%rbp), %rsi
movl $0xff, %edx
callq 0x26e0
movl %eax, -0x24(%rbp)
cmpl $0x0, -0x24(%rbp)
jle 0x3064
movl -0x24(%rbp), %esi
movq 0x561f(%rip), %rdi      # 0x7fd8
callq 0x2350
movq %rax, %rdi
movq 0x55f8(%rip), %rsi      # 0x7fc0
callq 0x2240
leaq -0x151(%rbp), %rdi
movq %rdi, -0x258(%rbp)
callq 0x2370
movq -0x258(%rbp), %rdx
leaq -0x150(%rbp), %rdi
leaq -0x130(%rbp), %rsi
callq 0x30b0
jmp 0x29fc
leaq -0x151(%rbp), %rdi
callq 0x2260
movq 0x55c9(%rip), %rdi      # 0x7fd8
leaq -0x150(%rbp), %rsi
callq 0x21f0
movq %rax, -0x260(%rbp)
jmp 0x2a24
movq -0x260(%rbp), %rdi
movq 0x558e(%rip), %rsi      # 0x7fc0
callq 0x2240
jmp 0x2a39
leaq -0x180(%rbp), %rdi
callq 0x3160
leaq -0x1a1(%rbp), %rdi
movq %rdi, -0x268(%rbp)
callq 0x2370
movq -0x268(%rbp), %rdx
leaq 0x2680(%rip), %rsi      # 0x50e6
leaq -0x1a0(%rbp), %rdi
callq 0x30b0
jmp 0x2a74
leaq -0x180(%rbp), %rdi
leaq -0x150(%rbp), %rsi
leaq -0x1a0(%rbp), %rdx
callq 0x2780
jmp 0x2a90
leaq -0x1a0(%rbp), %rdi
callq 0x2150
leaq -0x1a1(%rbp), %rdi
callq 0x2260
leaq -0x180(%rbp), %rdi
callq 0x3180
movq %rax, -0x1b0(%rbp)
leaq -0x180(%rbp), %rdi
callq 0x31f0
movq %rax, -0x1b8(%rbp)
leaq -0x1b0(%rbp), %rdi
leaq -0x1b8(%rbp), %rsi
callq 0x31b0
testb $0x1, %al
jne 0x2aea
jmp 0x3030
leaq -0x1b0(%rbp), %rdi
callq 0x3220
movq %rax, %rdi
leaq 0x260b(%rip), %rsi      # 0x510b
xorl %eax, %eax
movl %eax, %edx
callq 0x23c0
cmpq $-0x1, %rax
je 0x3014
leaq -0x1d0(%rbp), %rdi
movq %rdi, -0x270(%rbp)
callq 0x3160
movq -0x270(%rbp), %rdi
movl $0xf, %esi
callq 0x3240
jmp 0x2b39
leaq -0x1b0(%rbp), %rdi
callq 0x3340
movq %rax, -0x280(%rbp)
leaq -0x1f1(%rbp), %rdi
movq %rdi, -0x278(%rbp)
callq 0x2370
movq -0x278(%rbp), %rdx
leaq 0x25a4(%rip), %rsi      # 0x5111
leaq -0x1f0(%rbp), %rdi
callq 0x30b0
jmp 0x2b7b
movq -0x280(%rbp), %rsi
leaq -0x1d0(%rbp), %rdi
leaq -0x1f0(%rbp), %rdx
callq 0x2780
jmp 0x2b97
leaq -0x1f0(%rbp), %rdi
callq 0x2150
leaq -0x1f1(%rbp), %rdi
callq 0x2260
leaq -0x1d0(%rbp), %rdi
movl $0x2, %esi
callq 0x3390
movq %rax, -0x288(%rbp)
jmp 0x2bc9
movq -0x288(%rbp), %rdi
leaq 0x253c(%rip), %rsi      # 0x5113
callq 0x3360
movb %al, -0x289(%rbp)
jmp 0x2be4
movb -0x289(%rbp), %al
testb $0x1, %al
jne 0x2bf3
jmp 0x2ff8
movq 0x53de(%rip), %rdi      # 0x7fd8
leaq 0x2514(%rip), %rsi      # 0x5115
callq 0x2200
movq %rax, -0x298(%rbp)
jmp 0x2c0f
movq -0x298(%rbp), %rdi
movq 0x53a3(%rip), %rsi      # 0x7fc0
callq 0x2240
jmp 0x2c24
movq 0x53ad(%rip), %rdi      # 0x7fd8
leaq 0x24f4(%rip), %rsi      # 0x5126
callq 0x2200
movq %rax, -0x2a0(%rbp)
jmp 0x2c40
leaq -0x1d0(%rbp), %rdi
movl $0x5, %esi
callq 0x3390
movq %rax, -0x2a8(%rbp)
jmp 0x2c5a
movq -0x2a8(%rbp), %rsi
movq -0x2a0(%rbp), %rdi
callq 0x21f0
movq %rax, -0x2b0(%rbp)
jmp 0x2c76
movq -0x2b0(%rbp), %rdi
movq 0x533c(%rip), %rsi      # 0x7fc0
callq 0x2240
jmp 0x2c8b
movq 0x5346(%rip), %rdi      # 0x7fd8
leaq 0x249f(%rip), %rsi      # 0x5138
callq 0x2200
movq %rax, -0x2b8(%rbp)
jmp 0x2ca7
leaq -0x1d0(%rbp), %rdi
movl $0x3, %esi
callq 0x3390
movq %rax, -0x2c0(%rbp)
jmp 0x2cc1
movq -0x2c0(%rbp), %rsi
movq -0x2b8(%rbp), %rdi
callq 0x21f0
movq %rax, -0x2c8(%rbp)
jmp 0x2cdd
movq -0x2c8(%rbp), %rdi
movq 0x52d5(%rip), %rsi      # 0x7fc0
callq 0x2240
jmp 0x2cf2
leaq -0x1d0(%rbp), %rdi
movl $0x5, %esi
callq 0x3390
movq %rax, -0x2d0(%rbp)
jmp 0x2d0c
movq -0x2d0(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x33d0
movsd %xmm0, -0x2d8(%rbp)
jmp 0x2d26
movsd -0x2d8(%rbp), %xmm0
movsd %xmm0, -0x200(%rbp)
leaq -0x1d0(%rbp), %rdi
movl $0x3, %esi
callq 0x3390
movq %rax, -0x2e0(%rbp)
jmp 0x2d50
movq -0x2e0(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x33d0
movsd %xmm0, -0x2e8(%rbp)
jmp 0x2d6a
movsd -0x2e8(%rbp), %xmm0
movsd %xmm0, -0x208(%rbp)
cvttsd2si -0x200(%rbp), %eax
cltq
imulq $0x51eb851f, %rax, %rax # imm = 0x51EB851F
movq %rax, %rcx
shrq $0x3f, %rcx
sarq $0x25, %rax
addl %ecx, %eax
movl %eax, -0x20c(%rbp)
movsd -0x200(%rbp), %xmm0
movl -0x20c(%rbp), %eax
imull $0x64, %eax, %eax
cvtsi2sd %eax, %xmm1
subsd %xmm1, %xmm0
movsd 0x2249(%rip), %xmm1     # 0x5008
divsd %xmm1, %xmm0
movsd %xmm0, -0x218(%rbp)
cvtsi2sdl -0x20c(%rbp), %xmm0
movsd -0x218(%rbp), %xmm2
addsd %xmm2, %xmm0
movsd %xmm0, -0x220(%rbp)
cvttsd2si -0x208(%rbp), %eax
cltq
imulq $0x51eb851f, %rax, %rax # imm = 0x51EB851F
movq %rax, %rcx
shrq $0x3f, %rcx
sarq $0x25, %rax
addl %ecx, %eax
movl %eax, -0x224(%rbp)
movsd -0x208(%rbp), %xmm0
movl -0x224(%rbp), %eax
imull $0x64, %eax, %eax
cvtsi2sd %eax, %xmm2
subsd %xmm2, %xmm0
divsd %xmm1, %xmm0
movsd %xmm0, -0x230(%rbp)
cvtsi2sdl -0x224(%rbp), %xmm0
movsd -0x230(%rbp), %xmm1
addsd %xmm1, %xmm0
movsd %xmm0, -0x238(%rbp)
movsd -0x238(%rbp), %xmm0
movsd -0x220(%rbp), %xmm1
leaq -0x240(%rbp), %rdi
leaq -0x248(%rbp), %rsi
callq 0x4c00
jmp 0x2e71
movq 0x5160(%rip), %rdi      # 0x7fd8
movq 0x5141(%rip), %rsi      # 0x7fc0
callq 0x2240
jmp 0x2e86
movq 0x514b(%rip), %rdi      # 0x7fd8
leaq 0x228c(%rip), %rsi      # 0x5120
callq 0x2200
movq %rax, -0x2f0(%rbp)
jmp 0x2ea2
movq -0x2f0(%rbp), %rdi
movsd -0x248(%rbp), %xmm0
callq 0x23a0
movq %rax, -0x2f8(%rbp)
jmp 0x2ebf
movq -0x2f8(%rbp), %rdi
movq 0x50f3(%rip), %rsi      # 0x7fc0
callq 0x2240
jmp 0x2ed4
movq 0x50fd(%rip), %rdi      # 0x7fd8
leaq 0x2250(%rip), %rsi      # 0x5132
callq 0x2200
movq %rax, -0x300(%rbp)
jmp 0x2ef0
movq -0x300(%rbp), %rdi
movsd -0x240(%rbp), %xmm0
callq 0x23a0
movq %rax, -0x308(%rbp)
jmp 0x2f0d
movq -0x308(%rbp), %rdi
movq 0x50a5(%rip), %rsi      # 0x7fc0
callq 0x2240
jmp 0x2f22
jmp 0x2ff8
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x160(%rbp)
movl %eax, -0x164(%rbp)
leaq -0x151(%rbp), %rdi
callq 0x2260
jmp 0x3069
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x160(%rbp)
movl %eax, -0x164(%rbp)
jmp 0x3056
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x160(%rbp)
movl %eax, -0x164(%rbp)
jmp 0x2f93
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x160(%rbp)
movl %eax, -0x164(%rbp)
leaq -0x1a0(%rbp), %rdi
callq 0x2150
leaq -0x1a1(%rbp), %rdi
callq 0x2260
jmp 0x304a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x160(%rbp)
movl %eax, -0x164(%rbp)
jmp 0x3006
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x160(%rbp)
movl %eax, -0x164(%rbp)
jmp 0x2fea
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x160(%rbp)
movl %eax, -0x164(%rbp)
leaq -0x1f0(%rbp), %rdi
callq 0x2150
leaq -0x1f1(%rbp), %rdi
callq 0x2260
jmp 0x3006
leaq -0x1d0(%rbp), %rdi
callq 0x3410
jmp 0x3014
leaq -0x1d0(%rbp), %rdi
callq 0x3410
jmp 0x304a
jmp 0x3016
leaq -0x1b0(%rbp), %rdi
xorl %esi, %esi
callq 0x3470
movq %rax, -0x250(%rbp)
jmp 0x2abb
leaq -0x180(%rbp), %rdi
callq 0x3410
leaq -0x150(%rbp), %rdi
callq 0x2150
jmp 0x3064
leaq -0x180(%rbp), %rdi
callq 0x3410
leaq -0x150(%rbp), %rdi
callq 0x2150
jmp 0x3069
jmp 0x297b
movq -0x160(%rbp), %rdi
callq 0x2360
nopw %cs:(%rax,%rax)
nop