Skip to content

Commit

Permalink
Merge pull request #2 from LStudioLoren/dev
Browse files Browse the repository at this point in the history
重构了目录
  • Loading branch information
LStudioLoren authored Jun 28, 2021
2 parents 6e6c39c + 49547f5 commit 2b6562f
Show file tree
Hide file tree
Showing 25 changed files with 819 additions and 85 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
# 项目排除路径
/venv/
/venv/
/data/no_git_folder/
7 changes: 7 additions & 0 deletions .idea/encodings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

107 changes: 107 additions & 0 deletions Py_study/FirmwareUpdate.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
import binascii

import serial

import serial.tools.list_ports
import time
class serialConfig:

def initPort(self,portNum,baudrate):
self.ser = serial.Serial()
self.ser.port = "COM"+portNum
self.ser.baudrate = baudrate
self.ser.timeout = 1
self.ser.open()
if self.ser.isOpen():
return self.ser
else:
print("open serial error!check port num and baudrate!")

def updateFW(filepath,ser):
#fo = open("D:\program\python\SPPositionWithGPSandGLO\data\OM7MR0800RN0000.shex", mode='r', newline='\r\n')
fo = open(filepath, mode='r', newline='\r\n')

maxlenth = 0
# while True:
pack_data = ""
count = 0

while True:
#for i in range(10):
fline = fo.readline().strip()

if fline == "":
break


if fline.startswith("S0") or fline.startswith("S5") or fline.startswith("S7"):
pack_data = "SOFTLOADSREC \""+fline+"\"\r\n"
ser.write(pack_data.encode("utf8"))
print(pack_data)
#while True:
time.sleep(0.2)
if ser.inWaiting() > 0:
# ser.write("LOG version\r\n".encode("gbk"))

data_str = ser.read(ser.inWaiting()).decode('ascii')
print(data_str)
#print(ser.readlines())

#if check.find("OK") >0:
#break
#print()
pack_data = ""
elif fline.startswith("S3"):
line = fline.replace("S3", "", 1)
line_len = int(line[0:2], 16)
line_add = line[2:10]
line_data = line[10:line_len * 2]
# print(len(bytes(line_data, encoding='UTF8')))
pack_data += line_data
if len(bytes(pack_data, encoding='UTF8')) + 56 > 4096 or line_len < 33:
pack_data2 = "SOFTLOADDATA " + pack_data +"\r\n"
print(count,pack_data2)
ser.write(bytes(pack_data2))
#while True:
#check = ser.read(15)
#if check.find("OK") > 0:
#break
time.sleep(0.2)
if ser.inWaiting() > 0:
#ser.write("LOG version\r\n".encode("gbk"))

data_str = ser.read(ser.inWaiting()).decode('ascii')
print(data_str)
pack_data = ""
count += 1
ser.write(bytes("SOFTLOADCOMMIT", encoding='ascii'))
# while True:
# check = ser.read(15)
# if check.find("OK") > 0:
# break
time.sleep(0.2)
while True:
if ser.inWaiting() > 0:
# ser.write("LOG version\r\n".encode("gbk"))
data_str = ser.read(ser.inWaiting()).decode('ascii')
print(data_str)
# print("SOFTLOADDATA",fline,line_len,line_add,bytes(line_data,encoding='UTF8'))

if __name__ == '__main__':
ser = serialConfig().initPort("13",230400)
ser.write("SOFTLOADRESET\r\n".encode("ASCII"))
updateFW("/data/no_git_folder/OM7MR0800RN0000.shex", ser)
#for i in range(20):
#ser.write("log version\r\n".encode("gbk"))
# while True:
# if ser.inWaiting() > 0:
# ser.write("LOG version\r\n".encode("gbk"))
# time.sleep(0.2)
# data_str = ser.read(ser.inWaiting()).decode('ascii')
# print(data_str,end='')
# #else:
#break

#while True:
#print(ser.read(15))
#print(count)
2 changes: 2 additions & 0 deletions Py_study/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ def print_hi(name):
b=bytearray()
# 按间距中的绿色按钮以运行脚本。
if __name__ == '__main__':
a = "> 2021 01 12 08 21 48.0000000 0 56"
print(a[2:6],a[7:9],a[10:12],a[13:15],a[16:18],a[19:29])
#hex1[8] = (0x1B,0x04,0x50,0xB3,0xF2,0x8E,0x49,0x40)
#b = binascii.b2a_hex(int(0x1B0450B3F28E4940))
#print(b)
Expand Down
2 changes: 1 addition & 1 deletion Py_study/main_filetest.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import numpy as np
import struct
import binascii
from singlepoint import CoordinateTransformation
from position.singlepoint import CoordinateTransformation
import MSG.header as Header


Expand Down
36 changes: 29 additions & 7 deletions Py_study/read_rawdata.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
if __name__ == '__main__':
fo = open("../data/TLK_raw_data.txt",
fo = open("../data/no_git_folder/1v2-0622.txt",
mode='r', newline='\r\n')
fo2 = open("../data/TLK_raw_data2.txt",
fo2 = open("../data/no_git_folder/TLK_raw_data4.txt",
mode='w')
fuhao = 0
str = ""
Expand All @@ -18,8 +18,12 @@
strary = str.split("#")
for i in range(len(strary)-1):
#print("#"+strary[i])
fo2.write(strary[i].replace("..","")+"\r")

a = strary[i].replace("..","")
if a.startswith("#") :
a = a
else:
a = "#"+a
fo2.write(a + "\r")
str = "#"+strary[len(strary)-1]
#print("---re str:",str)
elif str.count("#")>0 and str.count("$") >0:
Expand All @@ -31,20 +35,38 @@
strary1 = str.split("$")
for i in range(len(strary1)-1):
#print("$" +strary1[i])
fo2.write(strary1[i].replace("..","") + "\r")
a = strary1[i].replace("..","")
if a.startswith("$"):
a = a
else:
a = "$" + a
fo2.write(a + "\r")

str = "$"+strary1[len(strary1)-1]

elif str.find("#")>str.find("$"):
strary1 = str.split("#")
for i in range(len(strary1) - 1):
#print("#"+strary1[i])
fo2.write(strary1[i].replace("..","") + "\r")
a = strary1[i].replace("..","")

if a.startswith("#"):
a = a
else:
a = "#" + a
fo2.write(a + "\r")
str = "#" + strary1[len(strary1) - 1]
elif str.count("$") >=2:
strary = str.split("$")
for i in range(len(strary) - 1):
#print("$" +strary[i])
fo2.write(strary[i].replace("..","") + "\r")
#fo2.write( + "\r")
a = strary[i].replace("..","")
if a.startswith("$"):
a = a
else:
a = "$" + a
fo2.write(a + "\r")
#fo2.write(strary[i] + "\r\n")
str = "$" + strary[len(strary) - 1]
#print("---re str:", str)
Expand Down
36 changes: 24 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,27 @@
# project1
学习PY,加使用PY实现卫星定位算法
# Py_study目录:
# SatellitePosition项目
此项目是关于学习PY,以及使用PY实现卫星定位算法,目前v1.0版本实现将rinex格式数据进行读取,并实现基于测距的单点定位算法。

## Py_study目录:
主要是关于py的一些学习,功能实现的方式等。

# singlepoint目录:
学习并实现卫星的基于伪距的单点定位算法实现。
## positon目录:
学习并实现卫星的定位算法,目前实现伪距单点定位算法

### 1、common目录:
- \_\_init\_\_:初始化类
- CoordinateTransformation.py:XYZ坐标系与BLH坐标系互相转换的功能类。
- NAVDATA.py:包含将rinex格式的星历文件进行提取转换的方法,并打包成星历类。
- OBSDATA.py:包含将rinex格式的观测量文件进行提取转换的方法,并打包成观测值类。
- SATPOS.py:用于计算卫星坐标的方法。
- tool.py:包含了一些常用的常参、数学方法等工具。
- solution.py:包含定位结果、历元时间、解算卫星数、定位状态、age等信息

### 2、singlepoint目录
- \_\_init\_\_:初始化类
- singlepoint.py:主函数。
- SINGLEPOINTPOSITION.py:实现单点定位算法。
### 3、rtkpoint目录
- \_\_init\_\_:初始化类
- rtkpoint.py:主函数。
- RTKPOSITION.py:实现RTK算法,正在完善

CoordinateTransformation.py:XYZ坐标系与BLH坐标系互相转换的功能类。
NAVDATA.py:包含将rinex格式的星历文件进行提取转换的方法,并打包成星历类。
OBSDATA.py:包含将rinex格式的观测量文件进行提取转换的方法,并打包成观测值类。
SATPOS.py:用于计算卫星坐标的方法。
singlepoint.py:主函数。
SINGLEPOINTPOSITION.py:实现单点定位算法。
tool.py:包含了一些常用的常参、数学方法等工具。
Loading

0 comments on commit 2b6562f

Please sign in to comment.