文件的播发,python,UDP协议

# -*- coding: utf-8 -*-
"""
Created on Mon Nov  6 17:49:55 2017


@author: ouyangmingjun
"""




'''
通过RTNET格式播发数据,一个历元一个历元播发,采用UDP协议,播发给本地电脑本地端口。
'''
import socket
import struct


BUF_SIZE = 1024
server_addr = ('127.0.0.1',8888)
client = socket.socket(socket.AF_INET,socket.SOCK_DGRAM)


count=0;
#不停的发送数据 ,没发一次尝试接受一次数据并打印
f=open(r'C:\Users\Administrator\Desktop\1.txt','r')
lines=f.readlines()
length=len(lines)
data=""
while True:
    if (lines[count].find("*")>=0):
         
        start=count
        while True:
             count+=1
             if (lines[count].find("EOE")>=0):
                 for i in range(start,count+1):
                     data=data+lines[i]
                 client.sendto(data.encode('utf-8'),server_addr)    
                 break
        count+=1
    if (count==length):
        break         
     
f.close()

client.close()



文件格式一个一个历元播发:


以下是本次播发文件的格式

* 2015 6 11 15 10 40.000000
VTEC 0 1 0 6 6 450000.0 20.4660 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 5.3590
9.6580 0.0000 0.0000 0.0000 0.0000 0.0000 -6.3610 -0.1210 1.1050 0.0000 0.0000
0.0000 0.0000 -2.7140 -1.8200 -0.9920 -0.6430 0.0000 0.0000 0.0000 1.9140
-0.5180 0.2530 0.0870 -0.0110 0.0000 0.0000 2.2950 1.0510 -0.9540 0.6220
-0.0720 -0.0810 0.0000 -0.9760 0.7570 0.2320 -0.2520 0.1970 -0.0680 -0.0280
0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.2720 0.0000 0.0000
0.0000 0.0000 0.0000 0.0000 1.1100 -1.0170 0.0000 0.0000 0.0000 0.0000 0.0000
-1.1500 0.5440 0.9890 0.0000 0.0000 0.0000 0.0000 -0.3770 -0.1990 0.2670
-0.0470 0.0000 0.0000 0.0000 0.6550 -0.0130 -0.2310 -0.4810 -0.3510 0.0000
0.0000 0.2360 -0.0710 0.0280 0.1900 -0.0810 0.0710
IND 0 1
G01 APC 3 -14442611.532 -13311059.070 -18020998.395 Clk 1 -1426.920500 Vel
3 2274.647600 -28.980300 -1787.861900 CoM 3 -14442612.572 -13311059.518
-18020999.539 CodeBias 6 1W -3.760000 1C -3.320000 2W -6.200000 2X -5.780000 1H
-3.350000 5I -5.430000 YawAngle 1 -0.315600 YawRate 1 0.0 PhaseBias 3 1C
3.9473 1 2 4 2W 6.3143 1 2 4 5I 6.7895 1 2 4
G02 APC 3 -8859103.160 14801278.856 20456920.800 Clk 1 171219.083500 Vel
3 -2532.296700 -161.275800 -1042.884100 CoM 3 -8859103.418 14801279.287
20456921.395 CodeBias 6 1W 3.930000 1C 3.610000 2W 6.480000 2X 0.000000 1H
3.580000 5I 0.000000 YawAngle 1 -0.693500 YawRate 1 0.0 PhaseBias 2 1C -4.0902
1 2 4 2W -6.7045 1 2 4
G03 APC 3 -13788295.679 -22525098.353 2644811.508 Clk 1 104212.074300 Vel
3 102.263400 -429.953400 -3150.231900 CoM 3 -13788296.829 -22525099.534
2644811.518 CodeBias 6 1W -2.650000 1C -2.160000 2W -4.360000 2X -4.480000 1H
-2.070000 5I -5.340000 YawAngle 1 -0.428800 YawRate 1 0.0 PhaseBias 3 1C
2.9024 1 2 2 2W 4.6124 1 2 2 5I 5.3694 1 2 2
R01 APC 3 -6783489.153 -23668850.753 6699094.457 Clk 1 - 45875.658100 Vel
3 -267.103000 -885.983700 -3403.253200 CoM 3 -6783489.307 -23668853.173
6699095.274 CodeBias 4 1P -2.496400 1C -2.490700 2P -4.126600 2C -3.156200
R02 APC 3 -11292959.022 -10047039.425 20577343.288 Clk 1 41215.750900 Vel
3 -476.369400 -2768.936600 -1620.000600 CoM 3 -11292959.672 -10047040.710
20577345.344 CodeBias 4 1P 0.211200 1C 0.391300 2P 0.349100 2C 0.406300
R03 APC 3 -9226469.614 9363128.850 21908853.313 Clk 1 13090.322800 Vel
3 -369.088600 -2964.934500 1111.041000 CoM 3 -9226470.226 9363129.442
21908855.791 CodeBias 4 1P 2.283800 1C 2.483800 2P 3.775300 2C 3.785500
E11 APC 3 2965877.898 17754418.441 23503540.946 Clk 1 33955.329000 Vel
3 -1923.398100 1361.709200 -784.555800 CoM 3 2965878.082 17754418.669
23503541.507 CodeBias 3 1B 1.382100 5Q 2.478400 7Q 2.503300
E12 APC 3 -14807433.144 21753389.581 13577231.476 Clk 1 -389652.211900 Vel
3 -1082.464300 825.868400 -2503.982200 CoM 3 -14807433.366 21753389.966
13577231.926 CodeBias 3 1B 0.386600 5Q 0.693300 7Q 0.534700
E19 APC 3 -15922225.351 8097517.292 23611910.403 Clk 1 -2551.650800 Vel
3 -183.377800 -2359.143700 684.105100 CoM 3 -15922225.569 8097517.329
23611910.995 CodeBias 3 1B -1.777000 5Q -3.186600 7Q -3.069100
EOE
* 2015 6 11 15 10 45.000000
VTEC 0 1 0 6 6 450000.0 20.4660 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 5.3590
9.6580 0.0000 0.0000 0.0000 0.0000 0.0000 -6.3610 -0.1210 1.1050 0.0000 0.0000
0.0000 0.0000 -2.7140 -1.8200 -0.9920 -0.6430 0.0000 0.0000 0.0000 1.9140
-0.5180 0.2530 0.0870 -0.0110 0.0000 0.0000 2.2950 1.0510 -0.9540 0.6220
-0.0720 -0.0810 0.0000 -0.9760 0.7570 0.2320 -0.2520 0.1970 -0.0680 -0.0280
0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.2720 0.0000 0.0000
0.0000 0.0000 0.0000 0.0000 1.1100 -1.0170 0.0000 0.0000 0.0000 0.0000 0.0000
-1.1500 0.5440 0.9890 0.0000 0.0000 0.0000 0.0000 -0.3770 -0.1990 0.2670
-0.0470 0.0000 0.0000 0.0000 0.6550 -0.0130 -0.2310 -0.4810 -0.3510 0.0000
0.0000 0.2360 -0.0710 0.0280 0.1900 -0.0810 0.0710
IND 0 1
G01 APC 3 -14442611.532 -13311059.070 -18020998.395 Clk 1 -1426.920500 Vel
3 2274.647600 -28.980300 -1787.861900 CoM 3 -14442612.572 -13311059.518
-18020999.539 CodeBias 6 1W -3.760000 1C -3.320000 2W -6.200000 2X -5.780000 1H
-3.350000 5I -5.430000 YawAngle 1 -0.315600 YawRate 1 0.0 PhaseBias 3 1C
3.9473 1 2 4 2W 6.3143 1 2 4 5I 6.7895 1 2 4
G02 APC 3 -8859103.160 14801278.856 20456920.800 Clk 1 171219.083500 Vel
3 -2532.296700 -161.275800 -1042.884100 CoM 3 -8859103.418 14801279.287
20456921.395 CodeBias 6 1W 3.930000 1C 3.610000 2W 6.480000 2X 0.000000 1H
3.580000 5I 0.000000 YawAngle 1 -0.693500 YawRate 1 0.0 PhaseBias 2 1C -4.0902
1 2 4 2W -6.7045 1 2 4
G03 APC 3 -13788295.679 -22525098.353 2644811.508 Clk 1 104212.074300 Vel
3 102.263400 -429.953400 -3150.231900 CoM 3 -13788296.829 -22525099.534
2644811.518 CodeBias 6 1W -2.650000 1C -2.160000 2W -4.360000 2X -4.480000 1H
-2.070000 5I -5.340000 YawAngle 1 -0.428800 YawRate 1 0.0 PhaseBias 3 1C
2.9024 1 2 2 2W 4.6124 1 2 2 5I 5.3694 1 2 2
R01 APC 3 -6783489.153 -23668850.753 6699094.457 Clk 1 - 45875.658100 Vel
3 -267.103000 -885.983700 -3403.253200 CoM 3 -6783489.307 -23668853.173
6699095.274 CodeBias 4 1P -2.496400 1C -2.490700 2P -4.126600 2C -3.156200
R02 APC 3 -11292959.022 -10047039.425 20577343.288 Clk 1 41215.750900 Vel
3 -476.369400 -2768.936600 -1620.000600 CoM 3 -11292959.672 -10047040.710
20577345.344 CodeBias 4 1P 0.211200 1C 0.391300 2P 0.349100 2C 0.406300
R03 APC 3 -9226469.614 9363128.850 21908853.313 Clk 1 13090.322800 Vel
3 -369.088600 -2964.934500 1111.041000 CoM 3 -9226470.226 9363129.442
21908855.791 CodeBias 4 1P 2.283800 1C 2.483800 2P 3.775300 2C 3.785500
E11 APC 3 2965877.898 17754418.441 23503540.946 Clk 1 33955.329000 Vel
3 -1923.398100 1361.709200 -784.555800 CoM 3 2965878.082 17754418.669
23503541.507 CodeBias 3 1B 1.382100 5Q 2.478400 7Q 2.503300
E12 APC 3 -14807433.144 21753389.581 13577231.476 Clk 1 -389652.211900 Vel
3 -1082.464300 825.868400 -2503.982200 CoM 3 -14807433.366 21753389.966
13577231.926 CodeBias 3 1B 0.386600 5Q 0.693300 7Q 0.534700
E19 APC 3 -15922225.351 8097517.292 23611910.403 Clk 1 -2551.650800 Vel
3 -183.377800 -2359.143700 684.105100 CoM 3 -15922225.569 8097517.329
23611910.995 CodeBias 3 1B -1.777000 5Q -3.186600 7Q -3.069100
EOE
* 2015 6 11 15 10 50.000000
VTEC 0 1 0 6 6 450000.0 20.4660 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 5.3590
9.6580 0.0000 0.0000 0.0000 0.0000 0.0000 -6.3610 -0.1210 1.1050 0.0000 0.0000
0.0000 0.0000 -2.7140 -1.8200 -0.9920 -0.6430 0.0000 0.0000 0.0000 1.9140
-0.5180 0.2530 0.0870 -0.0110 0.0000 0.0000 2.2950 1.0510 -0.9540 0.6220
-0.0720 -0.0810 0.0000 -0.9760 0.7570 0.2320 -0.2520 0.1970 -0.0680 -0.0280
0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.2720 0.0000 0.0000
0.0000 0.0000 0.0000 0.0000 1.1100 -1.0170 0.0000 0.0000 0.0000 0.0000 0.0000
-1.1500 0.5440 0.9890 0.0000 0.0000 0.0000 0.0000 -0.3770 -0.1990 0.2670
-0.0470 0.0000 0.0000 0.0000 0.6550 -0.0130 -0.2310 -0.4810 -0.3510 0.0000
0.0000 0.2360 -0.0710 0.0280 0.1900 -0.0810 0.0710
IND 0 1
G01 APC 3 -14442611.532 -13311059.070 -18020998.395 Clk 1 -1426.920500 Vel
3 2274.647600 -28.980300 -1787.861900 CoM 3 -14442612.572 -13311059.518
-18020999.539 CodeBias 6 1W -3.760000 1C -3.320000 2W -6.200000 2X -5.780000 1H
-3.350000 5I -5.430000 YawAngle 1 -0.315600 YawRate 1 0.0 PhaseBias 3 1C
3.9473 1 2 4 2W 6.3143 1 2 4 5I 6.7895 1 2 4
G02 APC 3 -8859103.160 14801278.856 20456920.800 Clk 1 171219.083500 Vel
3 -2532.296700 -161.275800 -1042.884100 CoM 3 -8859103.418 14801279.287
20456921.395 CodeBias 6 1W 3.930000 1C 3.610000 2W 6.480000 2X 0.000000 1H
3.580000 5I 0.000000 YawAngle 1 -0.693500 YawRate 1 0.0 PhaseBias 2 1C -4.0902
1 2 4 2W -6.7045 1 2 4
G03 APC 3 -13788295.679 -22525098.353 2644811.508 Clk 1 104212.074300 Vel
3 102.263400 -429.953400 -3150.231900 CoM 3 -13788296.829 -22525099.534
2644811.518 CodeBias 6 1W -2.650000 1C -2.160000 2W -4.360000 2X -4.480000 1H
-2.070000 5I -5.340000 YawAngle 1 -0.428800 YawRate 1 0.0 PhaseBias 3 1C
2.9024 1 2 2 2W 4.6124 1 2 2 5I 5.3694 1 2 2
R01 APC 3 -6783489.153 -23668850.753 6699094.457 Clk 1 - 45875.658100 Vel
3 -267.103000 -885.983700 -3403.253200 CoM 3 -6783489.307 -23668853.173
6699095.274 CodeBias 4 1P -2.496400 1C -2.490700 2P -4.126600 2C -3.156200
R02 APC 3 -11292959.022 -10047039.425 20577343.288 Clk 1 41215.750900 Vel
3 -476.369400 -2768.936600 -1620.000600 CoM 3 -11292959.672 -10047040.710
20577345.344 CodeBias 4 1P 0.211200 1C 0.391300 2P 0.349100 2C 0.406300
R03 APC 3 -9226469.614 9363128.850 21908853.313 Clk 1 13090.322800 Vel
3 -369.088600 -2964.934500 1111.041000 CoM 3 -9226470.226 9363129.442
21908855.791 CodeBias 4 1P 2.283800 1C 2.483800 2P 3.775300 2C 3.785500
E11 APC 3 2965877.898 17754418.441 23503540.946 Clk 1 33955.329000 Vel
3 -1923.398100 1361.709200 -784.555800 CoM 3 2965878.082 17754418.669
23503541.507 CodeBias 3 1B 1.382100 5Q 2.478400 7Q 2.503300
E12 APC 3 -14807433.144 21753389.581 13577231.476 Clk 1 -389652.211900 Vel
3 -1082.464300 825.868400 -2503.982200 CoM 3 -14807433.366 21753389.966
13577231.926 CodeBias 3 1B 0.386600 5Q 0.693300 7Q 0.534700
E19 APC 3 -15922225.351 8097517.292 23611910.403 Clk 1 -2551.650800 Vel
3 -183.377800 -2359.143700 684.105100 CoM 3 -15922225.569 8097517.329
23611910.995 CodeBias 3 1B -1.777000 5Q -3.186600 7Q -3.069100
EOE

前期播发时间发现python 太久了,后面改为用C语言播发。

发布了183 篇原创文章 · 获赞 107 · 访问量 29万+
展开阅读全文

没有更多推荐了,返回首页

©️2019 CSDN 皮肤主题: 书香水墨 设计师: CSDN官方博客

分享到微信朋友圈

×

扫一扫,手机浏览