社区
无线
帖子详情
gprs数据包长度可以多大?
own
2005-07-31 04:13:14
加精
我在用mc35通过gprs传输数据,数据长度为250个就不能发送成功了?200个可以,这主要是什么参数决定的?
...全文
854
17
打赏
收藏
gprs数据包长度可以多大?
我在用mc35通过gprs传输数据,数据长度为250个就不能发送成功了?200个可以,这主要是什么参数决定的?
复制链接
扫一扫
分享
转发到动态
举报
写回复
配置赞助广告
用AI写文章
17 条
回复
切换为时间正序
请发表友善的回复…
发表回复
打赏红包
caryyang
2006-01-08
打赏
举报
回复
是不是用的标准协议栈?
own
2005-12-17
打赏
举报
回复
fdyzhyzx(飞的叶子):我说的是终端不能发送,因为程序是自己写的,所以不知道哪里会有问题。还有就是怎样检测服务器处于半关闭状态?谢谢。
own
2005-12-16
打赏
举报
回复
回 fdyzhyzx(飞的叶子):程序是我写的,服务器程序(VB socket控件)不是我编的,终端主动发送数据服务器可以收到,但是服务器却不能发送数据,终端就一直不会发起连接请求,终端能不能监测到这种状态?
fdyzhyzx
2005-12-16
打赏
举报
回复
如果你是说服务器不能发250字节以上的数据那肯定不对吧,难道你的服务器也用的是无线模块。如果用WIN的网络编程,有可能在初试化CSocket的时候没有配置好,但默认也是512字节呀,你说的太少了!
fdyzhyzx
2005-12-15
打赏
举报
回复
都不对,楼住对程序还没理解。这里肯定不是你自己写的!?呵呵!在仔细琢磨一下吧。
own
2005-12-07
打赏
举报
回复
ronsan(酷沙):模块的发送缓存指的是gprs模块?
另:现在出现服务器发送断开命令,终端有时收不到,终端仍可以发送数据,怎样检测这种半关闭状态?
ronsan
2005-11-30
打赏
举报
回复
数据包的大小,应该是由模块的发送缓存来决定的。
我做GPRS时,发现达到700个字节时,发送过程中就会频繁的出现掉线和发送不出去的问题。
缓存的大小可咨询模块厂家。
但掉线的问题,就只能从协议中去查找了。
夜的眼
2005-11-18
打赏
举报
回复
1K多是正常的
goldencsf
2005-09-23
打赏
举报
回复
借地方问问
我要在一个嵌入式平台上通过MC35i发送彩信,怎么实现啊?
我只要负责把图片变成可以传输的数据包到TCP/IP层协议。
我是很菜很菜的新手,希望得到大家的帮助
wxf0204
2005-08-22
打赏
举报
回复
呵呵,楼上的,你倒是挺节省的哦!
充分的发扬勤俭节约的精神,好同志啊!
无响应
2005-08-21
打赏
举报
回复
借楼主宝地了,呵呵!
以上各位高手,小弟要开发GPRS,现在没有思路,请各位指点!
我以前使用MC35i作过短信的方式传输数据,现在客户要求必须GPRS的方式了。
我的QQ:314483554 欢迎各位加我,如果大家有现成的方案,我们可以合作,这样比较节省时间!
own
2005-08-18
打赏
举报
回复
我也感觉不应该,我在建立ppp的时候协商的是1460字节,那最可能使那里错了呢?
seanzh
2005-08-17
打赏
举报
回复
250字节?不可能的,你的设置有问题
own
2005-08-09
打赏
举报
回复
tcp连接建立的时候,选项04是什么意思?
那些选项是必需的?
own
2005-08-03
打赏
举报
回复
如果我把数据分2次发送,是不是必须等到第一个数据报的应答?实际中如果不等待应答,好像第二个数据报接收不到
wxf0204
2005-08-01
打赏
举报
回复
呵呵,这个是和你的传输协议有关系的, 一般的IP数据包的大小是1460BYTE ,我用的也是MC35I,使用TCP/IP协议,可以传输1460BYTE的数据.
own
2005-08-01
打赏
举报
回复
传输协议?你说的是哪一层协议?我用的是tcp协议,发送250个字节的数据,服务器端没反应
HexFileViewer.exe/二进制文件查看器/升级
数据包
查看器
Win10、Win7、XP系统用于STM32
GPRS
远程升级
数据包
分包。该工具可以打开,自定义
数据包
长度
,计算总包数量,已经锁打开文件的包含字节数数量,
C#写gps中心服务处理程序
要改协议,,高手帮下忙。。在线等。
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.Messaging;
using System.Net.Sockets;
using System.Text;
using System.Runtime.InteropServices;
using System.IO;
using System.Threading ;
using System.Net;
namespace
Gprs
Server
{
///
/// Form1 的摘要说明。
///
public class
Gprs
Server : System.Windows.Forms.Form
{
///
/// 必需的设计器变量。
///
[DllImport("User32.dll",EntryPoint="SendMessage")]
private static extern int
SendMessage(
int hWnd, // handle to destination window
int Msg, // message
int wParam, // first message parameter
string lParam // second message parameter
);
[DllImport("User32.dll",EntryPoint="FindWindow")]
private static extern int FindWindow(string lpClassName,string lpWindowName);
[DllImport("kernel32.dll")]
public static extern int GetPrivateProfileString ( string section ,string key , string def , StringBuilder retVal ,int size , string filePath ) ;
[DllImport("kernel32")]
public static extern long WritePrivateProfileString ( string section,string key,string val,string filePath ) ;
private System.ComponentModel.IContainer components;
public static int LocaPort;//本地端口
public static string RemoteIp;
public static int RemotePort;//远程端口
public static string sCompanyName;//公司名称
private Icon m_Icon1;
private Icon m_Icon2;
private Icon m_Icon3;
private NotifyIcon notifyIcon;
MenuItem menuItem1;
MenuItem menuItem2;
private Hashtable CarID_RemoteIP_Hash;
private Thread th
Gprs
;
private Thread thTcpMsg ;
private Socket socket;
private Socket TcpSocket;
private System.Windows.Forms.Timer TimerIcon;
private System.Windows.Forms.Label lblInfo;
private System.Windows.Forms.Timer TimerConn;
private byte[] TempBuff;
private System.Windows.Forms.CheckBox checkBox1;
private System.Windows.Forms.ImageList imgList;// = new byte[1024];
private byte[] TcpBuff;
private System.Windows.Forms.ListView lvwMsg;
private System.Windows.Forms.ColumnHeader sId;
private System.Windows.Forms.ColumnHeader sNote;
private System.Windows.Forms.Button cmdExit;
private System.Windows.Forms.Button cmdSet;// = new byte[2048];
private bool bTsFlag=false;
public
Gprs
Server()
{
InitializeComponent();
//检测配置文件目录是否存在
GetSysPra();
TempBuff= new byte[1];
TcpBuff=new byte[1];
m_Icon1 = new Icon("SysFile\\Icon1.ico");
m_Icon2 = new Icon("SysFile\\Icon2.ico");
m_Icon3 = new Icon("SysFile\\Icon3.ico");
notifyIcon = new NotifyIcon();
notifyIcon.Icon = m_Icon1;
notifyIcon.Text = sCompanyName;
notifyIcon.Visible = true;
menuItem1=new MenuItem("设置");
menuItem2=new MenuItem("退出");
menuItem1.Click+=new EventHandler(this.menuItem1_Click);
menuItem2.Click+=new EventHandler(this.menuItem2_Click);
notifyIcon.ContextMenu=new ContextMenu(new MenuItem[]{menuItem1,menuItem2});
notifyIcon.DoubleClick+=new System.EventHandler(this.notifyIcon_DBClick);
CarID_RemoteIP_Hash=new Hashtable();
th
Gprs
= new Thread(new ThreadStart(ReadUdp)) ;
//启动线程
th
Gprs
.IsBackground =true;//将线程作为后台线程处理,用途,当主线程关闭,子线程随着关闭
th
Gprs
.Start( );
try
{
IPHostEntry IPHost = Dns.Resolve(RemoteIp);
string []aliases = IPHost.Aliases;
IPAddress []addr = IPHost.AddressList;
EndPoint ep = new IPEndPoint(addr[0],RemotePort);
TcpSocket = new Socket(AddressFamily.InterNetwork,SocketType.Stream,ProtocolType.Tcp);
TcpSocket.Connect(ep);
thTcpMsg = new Thread (new ThreadStart(ReadTcpMsg)) ;
//启动线程
thTcpMsg.IsBackground =true;
thTcpMsg.Start( ) ;
lblInfo.Text ="系统运行正常,正在中转
GPRS
数据...";
}
catch
{}
}
private void GetSysPra()
{
StringBuilder temp = new StringBuilder(255);
if (Directory.Exists("SysIni"))
{
if (File.Exists("SysIni\\SysIni.ini"))
{
int i;
i= GetPrivateProfileString("PortIni","UdpPort","",temp,255,"SysIni\\SysIni.ini");
if (i==0)
{
LocaPort=8888;
WritePrivateProfileString("PortIni","UdpPort","8888","SysIni\\SysIni.ini");
}
else
{
LocaPort=int.Parse(temp.ToString( ));
}
i = GetPrivateProfileString("Company","Name","",temp,255,"SysIni\\SysIni.ini");
if (i==0)
{
sCompanyName="龙翰科技";
WritePrivateProfileString("Company","Name","龙翰科技","SysIni\\SysIni.ini");
}
else
{
sCompanyName=temp.ToString( );
}
i = GetPrivateProfileString("PortIni","TcpAddress","",temp,255,"SysIni\\SysIni.ini");
if (i==0)
{
RemoteIp="127.0.0.1";
WritePrivateProfileString("PortIni","TcpAddress","127.0.0.1","SysIni\\SysIni.ini");
}
else
{
RemoteIp=temp.ToString( );
}
i = GetPrivateProfileString("PortIni","TcpPort","",temp,255,"SysIni\\SysIni.ini");
if (i==0)
{
RemotePort=6666;
WritePrivateProfileString("PortIni","TcpPort","6666","SysIni\\SysIni.ini");
}
else
{
RemotePort=int.Parse(temp.ToString( ));
}
}
else
{
//File.Create("SysIni\\SysIni.ini",255);
LocaPort=8888;
WritePrivateProfileString("PortIni","UdpPort","8888","SysIni\\SysIni.ini");
sCompanyName="龙翰科技";
WritePrivateProfileString("Company","Name","龙翰科技","SysIni\\SysIni.ini");
RemoteIp="127.0.0.1";
WritePrivateProfileString("PortIni","TcpAddress","127.0.0.1","SysIni\\SysIni.ini");
RemotePort=6666;
WritePrivateProfileString("PortIni","TcpPort","6666","SysIni\\SysIni.ini");
}
}
else
{
Directory.CreateDirectory("SysIni");
//File.Create("SysIni\\SysIni.ini",255);
LocaPort=8888;
WritePrivateProfileString("PortIni","UdpPort","8888","SysIni\\SysIni.ini");
sCompanyName="龙翰科技";
WritePrivateProfileString("Company","Name","龙翰科技","SysIni\\SysIni.ini");
RemoteIp="127.0.0.1";
WritePrivateProfileString("PortIni","TcpAddress","127.0.0.1","SysIni\\SysIni.ini");
RemotePort=6666;
WritePrivateProfileString("PortIni","TcpPort","6666","SysIni\\SysIni.ini");
}
}
///
/// 清理所有正在使用的资源。
///
private void menuItem1_Click(object sender,System.EventArgs e)
{
//
}
private void menuItem2_Click(object sender,System.EventArgs e)
{
this.Close();
Application.Exit();
}
private void notifyIcon_DBClick(object sender, System.EventArgs e)
{
//
}
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
notifyIcon.Visible =false;;
notifyIcon.Icon=null;
notifyIcon.Dispose();
m_Icon1.Dispose();
m_Icon2.Dispose();
m_Icon3.Dispose();
}
base.Dispose( disposing );
}
#region Windows 窗体设计器生成的代码
///
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
///
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(
Gprs
Server));
this.TimerIcon = new System.Windows.Forms.Timer(this.components);
this.lblInfo = new System.Windows.Forms.Label();
this.TimerConn = new System.Windows.Forms.Timer(this.components);
this.lvwMsg = new System.Windows.Forms.ListView();
this.sId = new System.Windows.Forms.ColumnHeader();
this.sNote = new System.Windows.Forms.ColumnHeader();
this.imgList = new System.Windows.Forms.ImageList(this.components);
this.checkBox1 = new System.Windows.Forms.CheckBox();
this.cmdExit = new System.Windows.Forms.Button();
this.cmdSet = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// TimerIcon
//
this.TimerIcon.Enabled = true;
this.TimerIcon.Interval = 1000;
this.TimerIcon.Tick += new System.EventHandler(this.TimerIcon_Tick);
//
// lblInfo
//
this.lblInfo.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
this.lblInfo.Location = new System.Drawing.Point(4, 298);
this.lblInfo.Name = "lblInfo";
this.lblInfo.Size = new System.Drawing.Size(310, 23);
this.lblInfo.TabIndex = 0;
this.lblInfo.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
// TimerConn
//
this.TimerConn.Enabled = true;
this.TimerConn.Interval = 6000;
this.TimerConn.Tick += new System.EventHandler(this.TimerConn_Tick);
//
// lvwMsg
//
this.lvwMsg.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
this.sId,
this.sNote});
this.lvwMsg.FullRowSelect = true;
this.lvwMsg.Location = new System.Drawing.Point(2, 2);
this.lvwMsg.Name = "lvwMsg";
this.lvwMsg.Size = new System.Drawing.Size(564, 292);
this.lvwMsg.SmallImageList = this.imgList;
this.lvwMsg.TabIndex = 1;
this.lvwMsg.View = System.Windows.Forms.View.Details;
//
// sId
//
this.sId.Text = "";
this.sId.Width = 21;
//
// sNote
//
this.sNote.Text = "消息内容";
this.sNote.Width = 522;
//
// imgList
//
this.imgList.ColorDepth = System.Windows.Forms.ColorDepth.Depth16Bit;
this.imgList.ImageSize = new System.Drawing.Size(16, 16);
this.imgList.ImageStream = ((System.Windows.Forms.ImageListStreamer)(resources.GetObject("imgList.ImageStream")));
this.imgList.TransparentColor = System.Drawing.Color.Transparent;
//
// checkBox1
//
this.checkBox1.FlatStyle = System.Windows.Forms.FlatStyle.Popup;
this.checkBox1.Location = new System.Drawing.Point(332, 300);
this.checkBox1.Name = "checkBox1";
this.checkBox1.Size = new System.Drawing.Size(104, 19);
this.checkBox1.TabIndex = 2;
this.checkBox1.Text = "显示调试数据";
this.checkBox1.CheckedChanged += new System.EventHandler(this.checkBox1_CheckedChanged);
//
// cmdExit
//
this.cmdExit.FlatStyle = System.Windows.Forms.FlatStyle.Popup;
this.cmdExit.Location = new System.Drawing.Point(504, 298);
this.cmdExit.Name = "cmdExit";
this.cmdExit.Size = new System.Drawing.Size(60, 22);
this.cmdExit.TabIndex = 3;
this.cmdExit.Text = "退出(&E)";
this.cmdExit.Click += new System.EventHandler(this.cmdExit_Click);
//
// cmdSet
//
this.cmdSet.FlatStyle = System.Windows.Forms.FlatStyle.Popup;
this.cmdSet.Location = new System.Drawing.Point(432, 298);
this.cmdSet.Name = "cmdSet";
this.cmdSet.Size = new System.Drawing.Size(60, 22);
this.cmdSet.TabIndex = 4;
this.cmdSet.Text = "设置(&S)";
this.cmdSet.Click += new System.EventHandler(this.cmdSet_Click);
//
//
Gprs
Server
//
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.ClientSize = new System.Drawing.Size(566, 323);
this.Controls.Add(this.cmdSet);
this.Controls.Add(this.cmdExit);
this.Controls.Add(this.checkBox1);
this.Controls.Add(this.lvwMsg);
this.Controls.Add(this.lblInfo);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
this.MaximizeBox = false;
this.Name = "
Gprs
Server";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "中继服务器";
this.Load += new System.EventHandler(this.
Gprs
Server_Load);
this.ResumeLayout(false);
}
#endregion
///
/// 应用程序的主入口点。
///
[STAThread]
static void Main()
{
Application.Run(new
Gprs
Server());
}
private byte Get_CheckXor(ref byte[] temp,int len)
{
byte A=0;
for(int i=0;i
{
A^=temp[i];
}
return A;
}
private void ReadTcpMsg() //读取用户发送的指令数据
{
byte[] buff= new byte[2048];
string CartIpAddress="";//车辆的IP地址
EndPoint TempRemote = null;
int recv = 0;
byte[] Tbuff;
byte[] AllBuff;
int iLenght=0;
int iIndex=0;
int iLen=0;
int iXorValue=0;
while(true)
{
try
{
recv=TcpSocket.Receive(buff,0,TcpSocket.Available,SocketFlags.None);//读取数据内容
if (recv==0)
{
recv=TcpSocket.Receive(buff,0,TcpSocket.Available,SocketFlags.None);//读取数据内容
if (recv==0)
{
TcpSocket.Close();
break;
}
}
}
catch
{
break;
}
AllBuff=new byte[recv +TcpBuff.Length];
for (iIndex = 1; iIndex <=TcpBuff.Length; iIndex++)
{
AllBuff[iIndex-1]=TcpBuff[iIndex-1];
}
for (iIndex = 1; iIndex <=recv; iIndex++)
{
AllBuff[TcpBuff.Length+iIndex-1]=buff[iIndex-1];
}
for (iIndex = 1; iIndex <=AllBuff.Length; iIndex++)
{
iLenght=AllBuff.Length-iIndex+1;
if (iLenght<6)//检测
数据包
长度
{
//不完整,则将指令保存
if (iLenght>0)
{
TcpBuff=new byte[iLenght];
for (iLen = 1; iLen <=iLenght; iLen++)
{
TcpBuff[iLen-1]=AllBuff[iLen+iIndex-2];
}
}
break;
}
else
{
//检测当前指令是否是完整的指令,查找
数据包
头
if (AllBuff[iIndex-1]==0x29 & AllBuff[iIndex]==0x29)
{
if ((AllBuff.Length -iIndex)>=(AllBuff[iIndex+2]*256+ AllBuff[iIndex+3]+4))
{
//检测当前指令是否是完整的指令
if ((AllBuff[AllBuff[iIndex+2]*256+ AllBuff[iIndex+3]+iIndex+3])==0x0D)
{
//在接收的数据中获取单条完整的指令数据
Tbuff=new byte[AllBuff[iIndex+2]*256+ AllBuff[iIndex+3]+5];
for (iLen = 1; iLen <=Tbuff.Length; iLen++)
{
Tbuff[iLen-1]=AllBuff[iLen+iIndex-2];
}
iXorValue=Get_CheckXor(ref Tbuff,Tbuff.Length-2);
if(iXorValue!=Tbuff[Tbuff.Length-2])
{
//校验不合格,继续查找合法指令数据
continue;
}
else
{
if (bTsFlag)
{
string BuffToStr="";
for(int i=0;i
{
BuffToStr+=Tbuff[i].ToString("X2")+" ";
}
ShowSysMsg(BuffToStr,2);
}
//获取车载终端手机号
CartIpAddress=Tbuff[5]+"." +Tbuff[6] +"."+Tbuff[7] +"."+Tbuff[8];
TempRemote=(EndPoint)CarID_RemoteIP_Hash[CartIpAddress];
if( TempRemote==null)
{
if (bTsFlag)
{
ShowSysMsg("无法查找到接收数据的远程终节点!",3);
}
}
else
{
try
{
socket.SendTo(Tbuff,TempRemote);
if (bTsFlag)
{
ShowSysMsg("数据成功转发到车载终端!",1);
}
}
catch
{
if (bTsFlag)
{
ShowSysMsg("数据转发到车载终端失败!",3);
}
}
}
iIndex=iIndex+Tbuff.Length-1;
TcpBuff=new byte[1];
}
}
else
{
continue;
}
}
else
{
if ((AllBuff[iIndex+2]*256+ AllBuff[iIndex+3]+4)>1024)
{
continue;
}
else
{
//不完整,则将指令保存
if (iLenght>0)
{
TcpBuff=new byte[iLenght];
for (iLen = 1; iLen <=iLenght; iLen++)
{
TcpBuff[iLen-1]=AllBuff[iLen+iIndex-2];
}
break;
}
else
{
TcpBuff=new byte[1];
break;
}
}
}
}
else
{
continue;
}
}//检测
数据包
长度
}
}
}
public void ShowSysMsg(string sNote,int iIcon)
{
//显示系统消息
try
{
lvwMsg.BeginUpdate();
if (lvwMsg.Items.Count >100)
lvwMsg.Items.Clear();
ListViewItem li = new ListViewItem();
//li.SubItems[0].Text =sNote ;
li.SubItems.Add (sNote);
li.ImageIndex=iIcon;
lvwMsg.Items.Add(li);
lvwMsg.EndUpdate();
}
catch
{}
}
private void ReadUdp() //从UDP数据端口读取
GPRS
数据
{
byte[] buff = new byte[1024];
int recv = 0;
byte[] Tbuff;
byte[] AllBuff;
int iLenght=0;
int iIndex=0;
int iLen=0;
int iXorValue=0;
string CarIpAddress="";
byte[] RecvAffirmBuff=new byte[]{0x29,0x29,0x21,0x00,0x05,0,0,0,0,0x0D};//回应终端数组
IPEndPoint ipep = new IPEndPoint(IPAddress.Any ,LocaPort);
//socket = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);
socket = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);
try
{
socket.Bind(ipep);
ShowSysMsg("系统成功在"+LocaPort + "端口侦听!",6);
}
catch
{
ShowSysMsg("端口"+LocaPort+"已被占用,系统侦听失败!",5);
return;
}
IPEndPoint sender = new IPEndPoint(IPAddress.Any , 0);//指远程终端(终节点)Ip地址对象 IPAddress.Any表示任何地址 0 表示任何端口
EndPoint remote = (EndPoint)(sender); //指远程终端(终节点)
while(true)
{
try
{
recv = socket.ReceiveFrom(buff , ref remote);
}
catch
{
ShowSysMsg("接收车载终端数据错误!",3);
}
//---------------------you2004-12-31 begin------------------------------//
AllBuff=new byte[recv +TempBuff.Length];
for (iIndex = 1; iIndex <=TempBuff.Length; iIndex++)
{
AllBuff[iIndex-1]=TempBuff[iIndex-1];
}
for (iIndex = 1; iIndex <=recv; iIndex++)
{
AllBuff[TempBuff.Length+iIndex-1]=buff[iIndex-1];
}
for (iIndex = 1; iIndex <=AllBuff.Length; iIndex++)
{
iLenght=AllBuff.Length-iIndex+1;
if (iLenght<6)//检测
数据包
长度
{
//不完整,则将指令保存
if (iLenght>0)
{
TempBuff=new byte[iLenght];
for (iLen = 1; iLen <=iLenght; iLen++)
{
TempBuff[iLen-1]=AllBuff[iLen+iIndex-2];
}
}
break;
}
else
{
//检测当前指令是否是完整的指令,查找
数据包
头
if (AllBuff[iIndex-1]==0x29 & AllBuff[iIndex]==0x29)
{
if ((AllBuff.Length -iIndex)>=(AllBuff[iIndex+2]*256+ AllBuff[iIndex+3]+4))
{
//检测当前指令是否是完整的指令
if ((AllBuff[AllBuff[iIndex+2]*256+ AllBuff[iIndex+3]+iIndex+3])==0x0D)
{
//在接收的数据中获取单条完整的指令数据
Tbuff=new byte[AllBuff[iIndex+2]*256+ AllBuff[iIndex+3]+5];
for (iLen = 1; iLen <=Tbuff.Length; iLen++)
{
Tbuff[iLen-1]=AllBuff[iLen+iIndex-2];
}
iXorValue=Get_CheckXor(ref Tbuff,Tbuff.Length-2);
if(iXorValue!=Tbuff[Tbuff.Length-2])
{
//校验不合格,继续查找合法指令数据
continue;
}
else
{
if (bTsFlag)
{
string BuffToStr="";
for(int i=0;i
{
BuffToStr+=Tbuff[i].ToString("X2")+" ";
}
ShowSysMsg(BuffToStr,0);
}
//获取车载终端手机号
CarIpAddress=Tbuff[5]+"." +Tbuff[6] +"."+Tbuff[7] +"."+Tbuff[8];
//-----------------检测系统哈希表是否包含此终端数据---------------------\\
if(CarID_RemoteIP_Hash.ContainsKey(CarIpAddress))
{
CarID_RemoteIP_Hash[CarIpAddress]=remote;//有更新
}
else
{
CarID_RemoteIP_Hash.Add(CarIpAddress,remote);//没有添加
}
//--------------------将数据转发到中心处理程序-----------------\\
if (TcpSocket.Connected)
{
try
{
TcpSocket.Send(Tbuff,0,Tbuff.Length,SocketFlags.None);
if (bTsFlag)
{
ShowSysMsg("数据成功转发到网络中心处理程序!",1);
}
}
catch
{
if (bTsFlag)
{
ShowSysMsg("数据转发到网络中心处理程序失败!",3);
}
}
}
//-------------------向终端发出0x21的接收确认-------------------\\
RecvAffirmBuff[5]=Tbuff[Tbuff.Length-2];
RecvAffirmBuff[6]=Tbuff[2];
RecvAffirmBuff[7]=Tbuff[9];
RecvAffirmBuff[8]=Get_CheckXor(ref RecvAffirmBuff,8);
socket.SendTo(RecvAffirmBuff,remote);
iIndex=iIndex+Tbuff.Length-1;
TempBuff=new byte[1];
}
}
else
{
continue;
}
}
else
{
if ((AllBuff[iIndex+2]*256+ AllBuff[iIndex+3]+4)>1024)
{
continue;
}
else
{
//不完整,则将指令保存
if (iLenght>0)
{
TempBuff=new byte[iLenght];
for (iLen = 1; iLen <=iLenght; iLen++)
{
TempBuff[iLen-1]=AllBuff[iLen+iIndex-2];
}
break;
}
else
{
TempBuff=new byte[1];
break;
}
}
}
}
else
{
continue;
}
}//检测
数据包
长度
}
//---------------------you2004-12-31 end------------------------------//
}
}
private void
Gprs
Server_Load(object sender, System.EventArgs e)
{
//
}
int I=0;
private void TimerIcon_Tick(object sender, System.EventArgs e)
{
if(th
Gprs
!=null)
{
if(th
Gprs
.IsAlive)
notifyIcon.Icon=notifyIcon.Icon==m_Icon1?m_Icon2:m_Icon1;
else
notifyIcon.Icon=notifyIcon.Icon==m_Icon1?m_Icon3:m_Icon1;
}
I++;
if(I>5)
{
I=FindWindow(null,@sCompanyName);
if( I!= 0)
{
SendMessage(I,0x501,1002,"");
}
I=0;
}
}
private void TimerConn_Tick(object sender, System.EventArgs e)
{
if (!TcpSocket.Connected)
{
try
{
lblInfo.Text ="与中心数据处理程序断开,正在进行二次连接...";
IPHostEntry IPHost = Dns.Resolve(RemoteIp);
string []aliases = IPHost.Aliases;
IPAddress []addr = IPHost.AddressList;
EndPoint ep = new IPEndPoint(addr[0],RemotePort);
TcpSocket = new Socket(AddressFamily.InterNetwork,SocketType.Stream,ProtocolType.Tcp);
TcpSocket.Connect(ep);
thTcpMsg = new Thread ( new ThreadStart(ReadTcpMsg)) ;
//启动线程
thTcpMsg.IsBackground =true;
thTcpMsg.Start( ) ;
lblInfo.Text ="系统运行正常,正在中转
GPRS
数据...";
}
catch
{
return;
}
}
}
private void checkBox1_CheckedChanged(object sender, System.EventArgs e)
{
bTsFlag=checkBox1.Checked;
}
private void cmdExit_Click(object sender, System.EventArgs e)
{
if(MessageBox.Show("确定关闭中继服务器?", "提示",MessageBoxButtons.YesNo,MessageBoxIcon.Information) == DialogResult.Yes)
{
Application.Exit ();
}
}
private void cmdSet_Click(object sender, System.EventArgs e)
{
frmUdpSet frmudpset=new frmUdpSet();
frmudpset.Show();
}
protected override void OnClosing(CancelEventArgs e)
{
e.Cancel =true;
this.WindowState =FormWindowState.Minimized;
}
}
}
stm32嵌入式开发实战入门与提高
本课程以实际操作演练的方式,以stm32系列单片机为例,手把手教你进行...掌握第三方库FAT,USB,emWin,TouchGFX,Lwip,FreeRTOS开发应用,通讯协议开发,AT指令开发,4G
GPRS
, MQTT物联网项目开发相关方面的知识。
GSM模块_
GPRS
传输长
数据包
时的经验总结
本文简单介绍了GSM模块串口中断的设计,数据存储方式的设计,以及数据
长度
较大时应该注意的地方,供大家设计的时候参考。
GPRS
详解
1:什么是
GPRS
? 2:
GPRS
/GSM模块功能通俗概述? 3:两个
GPRS
模块之间能进行通信吗? 4:
GPRS
模块可以作为DTU来使用吗? 5:
GPRS
/GSM模块的典型应用? 6:常用的几种
GPRS
/GSM模块和选型? 1:什么是
GPRS
GSM ? 目前,第二代移动通信技术(GSM)逐渐向第三代移动通信技术 3G)发展,而
GPRS
(通用分组无线业务)作为GSM向3G的过渡技术,就成为了连接...
无线
3,846
社区成员
5,006
社区内容
发帖
与我相关
我的任务
无线
硬件/嵌入开发 无线
复制链接
扫一扫
分享
社区描述
硬件/嵌入开发 无线
社区管理员
加入社区
获取链接或二维码
近7日
近30日
至今
加载中
查看更多榜单
社区公告
暂无公告
试试用AI创作助手写篇文章吧
+ 用AI写文章