Skip to content
切换导航条
切换导航条
当前项目
正在载入...
登录
顾剑亮
/
RFID
转到一个项目
切换导航栏
切换导航栏固定状态
项目
群组
代码片段
帮助
项目
活动
版本库
图表
网络
创建新的问题
提交
问题看板
文件
提交
网络
比较
分支
标签
Commit a366373a
由
刘韬
编写于
2022-12-19 10:12:34 +0800
浏览文件
选项
浏览文件
标签
下载
电子邮件补丁
差异文件
1
1 个父辈
20ecde30
隐藏空白字符变更
内嵌
并排
正在显示
22 个修改的文件
包含
140 行增加
和
16 行删除
.vs/RFID/v16/.suo
RFID_PuYue/PuYueRFID_C2S.cs
RFID_PuYue/PuYueRFID_FR540SP_C2S.cs
RFID_PuYue/PuYue_FR540SP.cs
RFID_PuYue/bin/Debug/Asa.RFID.PuYue.dll
RFID_PuYue/bin/Debug/Asa.RFID.PuYue.pdb
RFID_PuYue/bin/Debug/Asa.RFID.PuYue.xml
RFID_PuYue/obj/Debug/Asa.RFID.PuYue.dll
RFID_PuYue/obj/Debug/Asa.RFID.PuYue.pdb
RFID_PuYue/obj/Debug/RFID_PuYue.csproj.AssemblyReference.cache
RFID_PuYue/obj/Debug/RFID_PuYue.csproj.FileListAbsolute.txt
RFID_PuYue_Debug/Program.cs
RFID_PuYue_Debug/bin/Debug/Asa.RFID.PuYue.dll
RFID_PuYue_Debug/bin/Debug/Asa.RFID.PuYue.pdb
RFID_PuYue_Debug/bin/Debug/Asa.RFID.PuYue.xml
RFID_PuYue_Debug/bin/Debug/Debug.zip
RFID_PuYue_Debug/bin/Debug/RFID_HiStation_Debug.exe
RFID_PuYue_Debug/bin/Debug/RFID_HiStation_Debug.pdb
RFID_PuYue_Debug/obj/Debug/RFID_HiStation_Debug.exe
RFID_PuYue_Debug/obj/Debug/RFID_HiStation_Debug.pdb
RFID_PuYue_Debug/obj/Debug/RFID_PuYue_Debug.csproj.AssemblyReference.cache
RFID_PuYue_Debug/obj/Debug/RFID_PuYue_Debug.csproj.GenerateResource.cache
.vs/RFID/v16/.suo
查看文件 @
a366373
此文件类型无法预览
RFID_PuYue/PuYueRFID_C2S.cs
查看文件 @
a366373
...
...
@@ -396,6 +396,7 @@ public class PuYueRFID_C2S
catch
(
SocketException
exception1
)
{
errmsg
=
exception1
.
ToString
();
Open
();
return
false
;
}
catch
(
Exception
ex
)
...
...
RFID_PuYue/PuYueRFID_FR540SP_C2S.cs
查看文件 @
a366373
...
...
@@ -20,10 +20,8 @@ public class PuYueRFID_FR540SP_C2S
/// 连接状态变化, 手动连接不触发
/// </summary>
public
event
EventHandler
<
bool
>
ConnectionState_Event
;
public
PuYueRFID_FR540SP_C2S
(
string
ip
,
bool
automode
=
false
)
public
PuYueRFID_FR540SP_C2S
()
{
this
.
IP
=
ip
;
Automode
=
automode
;
//DOdata[0] = 0x00;
//DOdata[1] = 0x00;
//if (autoread)
...
...
@@ -42,8 +40,10 @@ public class PuYueRFID_FR540SP_C2S
/// 打开IO
/// </summary>
/// <returns></returns>
public
bool
Open
()
public
bool
Open
(
string
ip
,
bool
automode
=
false
)
{
this
.
IP
=
ip
;
Automode
=
automode
;
tcpClient
.
Dispose
();
tcpClient
=
new
TcpClient
();
...
...
@@ -61,8 +61,8 @@ public class PuYueRFID_FR540SP_C2S
if
(
Automode
)
{
iomonitorrun
=
true
;
iomonitorThread
=
new
Thread
(
new
ThreadStart
(
iomonitor
));
iomonitorThread
.
Start
();
//
iomonitorThread = new Thread(new ThreadStart(iomonitor));
//
iomonitorThread.Start();
}
ConnectionState_Event
?.
Invoke
(
this
,
true
);
return
true
;
...
...
@@ -124,7 +124,7 @@ public class PuYueRFID_FR540SP_C2S
/// </summary>
public
bool
IsConn
{
get
=>
iomonitorrun
&&
systemrun
&&
tcpClient
.
Connected
;
get
=>
tcpClient
.
Connected
;
}
bool
iomonitorrun
=
false
;
...
...
@@ -156,7 +156,7 @@ public class PuYueRFID_FR540SP_C2S
do
{
Thread
.
Sleep
(
1000
);
}
while
(
systemrun
&&
!
Open
());
}
while
(
systemrun
&&
!
Open
(
IP
,
Automode
));
}
}
...
...
@@ -275,7 +275,7 @@ public class PuYueRFID_FR540SP_C2S
{
seqadd
();
tcpClient
.
Client
.
Send
(
by
);
Thread
.
Sleep
(
5
);
Thread
.
Sleep
(
10
);
ulength
=
tcpClient
.
Client
.
Receive
(
result
);
}
...
...
@@ -339,7 +339,7 @@ public class PuYueRFID_FR540SP_C2S
}
catch
{
Open
();
Open
(
IP
,
Automode
);
return
-
1
;
}
}
...
...
@@ -387,12 +387,13 @@ public class PuYueRFID_FR540SP_C2S
seqadd
();
tcpClient
.
Client
.
Send
(
by
);
Thread
.
Sleep
(
5
);
Thread
.
Sleep
(
10
);
ulength
=
tcpClient
.
Client
.
Receive
(
result
);
}
catch
(
SocketException
se
)
{
Open
(
IP
,
Automode
);
return
false
;
}
}
...
...
@@ -486,11 +487,13 @@ public class PuYueRFID_FR540SP_C2S
seqadd
();
tcpClient
.
Client
.
Send
(
by
);
Thread
.
Sleep
(
10
);
var
ulength
=
tcpClient
.
Client
.
Receive
(
result
);
var
newResult
=
result
.
ToList
().
Take
(
ulength
).
ToArray
();
if
(
newResult
[
0
]
==
seqhead
[
0
]
&&
newResult
[
1
]
==
seqhead
[
1
])
{
//if (newResult[7] == 0x90)
// return false;
Console
.
WriteLine
(
BitConverter
.
ToString
(
newResult
));
return
true
;
}
...
...
@@ -501,11 +504,39 @@ public class PuYueRFID_FR540SP_C2S
}
catch
{
Open
(
IP
,
Automode
);
return
false
;
}
}
}
void
seqadd
()
public
bool
WriteEPC
(
byte
[]
data
)
{
bool
rtn
=
WriteByte
(
0x227
,
data
);
return
rtn
;
}
public
bool
ReadEPC
(
short
len
,
out
byte
[]
value
)
{
var
rtn
=
ReadByte
(
0x0227
,
len
,
out
value
);
return
rtn
;
}
/// <summary>
/// 16进制转换
/// </summary>
/// <param name="buff"></param>
/// <returns></returns>
public
string
HexBuff
(
byte
[]
buff
)
{
string
s
=
""
;
if
(
buff
==
null
)
return
s
;
for
(
int
i
=
0
;
i
<
buff
.
Length
;
i
++)
s
+=
buff
[
i
].
ToString
(
"X2"
)
+
" "
;
return
s
;
}
void
seqadd
()
{
seq
++;
if
(
seq
>=
ushort
.
MaxValue
-
10
)
...
...
RFID_PuYue/PuYue_FR540SP.cs
查看文件 @
a366373
...
...
@@ -543,6 +543,68 @@ namespace Asa.RFID
}
}
private
void
Write
(
short
address
,
byte
[]
value
)
{
if
(!
IsConn
)
return
;
byte
[]
temp
;
byte
[]
buffer
=
new
byte
[
10
];
GetMark
();
temp
=
BitConverter
.
GetBytes
(
_mark
);
//事务处理标识
buffer
[
0
]
=
temp
[
1
];
//高位
buffer
[
1
]
=
temp
[
0
];
//低位
buffer
[
2
]
=
0
;
buffer
[
3
]
=
0
;
//协议标识
buffer
[
4
]
=
0
;
buffer
[
5
]
=
15
;
//后面字节数
buffer
[
6
]
=
0xFF
;
//主设备
buffer
[
7
]
=
0x10
;
//功能码
temp
=
BitConverter
.
GetBytes
(
address
);
//寄存器起始地址
buffer
[
8
]
=
temp
[
1
];
//高位
buffer
[
9
]
=
temp
[
0
];
//低位
//buffer[10] = 0;
//buffer[11] = 4; //寄存器个数
//buffer[12] = 8; //数据长度
//buffer[13] = 0x5A;
//buffer[14] = (byte)value[0];
//buffer[15] = Convert.ToByte(value.Substring(1));
//buffer[16] = 0;
//buffer[17] = 0;
//buffer[18] = 0x4A;
//buffer[19] = 0;
//buffer[20] = 0;
List
<
byte
>
lb
=
new
List
<
byte
>(
buffer
);
List
<
byte
>
vd
=
new
List
<
byte
>(
value
);
if
(
value
.
Length
%
2
!=
0
)
vd
.
Add
(
0
);
var
registerlen
=
value
.
Length
/
2
;
var
regb
=
BitConverter
.
GetBytes
(
registerlen
);
lb
.
Add
(
regb
[
1
]);
lb
.
Add
(
regb
[
0
]);
lb
.
Add
((
byte
)(
registerlen
*
2
));
lb
.
AddRange
(
vd
);
lb
[
5
]
=
(
byte
)(
lb
.
Count
-
6
);
buffer
=
lb
.
ToArray
();
try
{
_total
=
false
;
//Common.log.Debug("Write[" + IP + "] " + HexBuff(buffer));
if
(
_client
!=
null
)
_client
.
Send
(
buffer
);
}
catch
(
Exception
ex
)
{
IsConn
=
false
;
//Common.log.Error(string.Format("Write[{0}] ERROR", IP), ex);
}
}
/// <summary>
/// 写入保持寄存器,0x10功能码
...
...
RFID_PuYue/bin/Debug/Asa.RFID.PuYue.dll
查看文件 @
a366373
此文件类型无法预览
RFID_PuYue/bin/Debug/Asa.RFID.PuYue.pdb
查看文件 @
a366373
此文件类型无法预览
RFID_PuYue/bin/Debug/Asa.RFID.PuYue.xml
查看文件 @
a366373
...
...
@@ -239,7 +239,7 @@
销毁
</summary>
</member>
<member
name=
"M:PuYueRFID_FR540SP_C2S.Open"
>
<member
name=
"M:PuYueRFID_FR540SP_C2S.Open
(System.String,System.Boolean)
"
>
<summary>
打开IO
</summary>
...
...
@@ -294,6 +294,13 @@
<param
name=
"data"
></param>
<returns></returns>
</member>
<member
name=
"M:PuYueRFID_FR540SP_C2S.HexBuff(System.Byte[])"
>
<summary>
16进制转换
</summary>
<param
name=
"buff"
></param>
<returns></returns>
</member>
<member
name=
"E:PuYueRFID_C2S.ConnectionState_Event"
>
<summary>
连接状态变化, 手动连接不触发
...
...
RFID_PuYue/obj/Debug/Asa.RFID.PuYue.dll
查看文件 @
a366373
此文件类型无法预览
RFID_PuYue/obj/Debug/Asa.RFID.PuYue.pdb
查看文件 @
a366373
此文件类型无法预览
RFID_PuYue/obj/Debug/RFID_PuYue.csproj.AssemblyReference.cache
查看文件 @
a366373
此文件类型无法预览
RFID_PuYue/obj/Debug/RFID_PuYue.csproj.FileListAbsolute.txt
查看文件 @
a366373
...
...
@@ -8,10 +8,10 @@ C:\Neotel\Program\RFID\RFID_PuYue\obj\Debug\RFID_PuYue.csprojAssemblyReference.c
D:\rick\vs\RFID\RFID_PuYue\bin\Debug\Asa.RFID.PuYue.xml
D:\rick\vs\RFID\RFID_PuYue\bin\Debug\Asa.RFID.PuYue.dll
D:\rick\vs\RFID\RFID_PuYue\bin\Debug\Asa.RFID.PuYue.pdb
D:\rick\vs\RFID\RFID_PuYue\obj\Debug\RFID_PuYue.csproj.AssemblyReference.cache
D:\rick\vs\RFID\RFID_PuYue\obj\Debug\RFID_PuYue.csproj.CoreCompileInputs.cache
D:\rick\vs\RFID\RFID_PuYue\obj\Debug\Asa.RFID.PuYue.dll
D:\rick\vs\RFID\RFID_PuYue\obj\Debug\Asa.RFID.PuYue.pdb
D:\rick\vs\RFID\RFID_PuYue\bin\Debug\log4net.dll
D:\rick\vs\RFID\RFID_PuYue\bin\Debug\log4net.xml
D:\rick\vs\RFID\RFID_PuYue\obj\Debug\RFID_PuYue.csproj.CopyComplete
D:\rick\vs\RFID\RFID_PuYue\obj\Debug\RFID_PuYue.csproj.AssemblyReference.cache
RFID_PuYue_Debug/Program.cs
查看文件 @
a366373
using
System
;
using
System.Collections.Generic
;
using
System.Linq
;
using
System.Text
;
using
System.Threading
;
using
System.Threading.Tasks
;
using
System.Windows.Forms
;
...
...
@@ -14,6 +16,20 @@ namespace RFID_PuYue_Debug
[
STAThread
]
static
void
Main
()
{
//PuYueRFID_FR540SP_C2S rfid = new PuYueRFID_FR540SP_C2S();
//rfid.Open("192.168.3.7");
//var epc = "20418002Z-203";
//epc = epc.PadRight(16);
//var result=rfid.WriteEPC(Encoding.ASCII.GetBytes(epc));
//Thread.Sleep(500);
//for (int i = 0; i < 5; i++)
//{
// if (rfid.ReadEPC(16, out byte[] data))
// {
// var txt = Encoding.ASCII.GetString(data);
// break;
// }
//}
Application
.
EnableVisualStyles
();
Application
.
SetCompatibleTextRenderingDefault
(
false
);
Application
.
Run
(
new
FrmMain
());
...
...
RFID_PuYue_Debug/bin/Debug/Asa.RFID.PuYue.dll
查看文件 @
a366373
此文件类型无法预览
RFID_PuYue_Debug/bin/Debug/Asa.RFID.PuYue.pdb
查看文件 @
a366373
此文件类型无法预览
RFID_PuYue_Debug/bin/Debug/Asa.RFID.PuYue.xml
查看文件 @
a366373
...
...
@@ -239,7 +239,7 @@
销毁
</summary>
</member>
<member
name=
"M:PuYueRFID_FR540SP_C2S.Open"
>
<member
name=
"M:PuYueRFID_FR540SP_C2S.Open
(System.String,System.Boolean)
"
>
<summary>
打开IO
</summary>
...
...
@@ -294,6 +294,13 @@
<param
name=
"data"
></param>
<returns></returns>
</member>
<member
name=
"M:PuYueRFID_FR540SP_C2S.HexBuff(System.Byte[])"
>
<summary>
16进制转换
</summary>
<param
name=
"buff"
></param>
<returns></returns>
</member>
<member
name=
"E:PuYueRFID_C2S.ConnectionState_Event"
>
<summary>
连接状态变化, 手动连接不触发
...
...
RFID_PuYue_Debug/bin/Debug/Debug.zip
查看文件 @
a366373
此文件类型无法预览
RFID_PuYue_Debug/bin/Debug/RFID_HiStation_Debug.exe
查看文件 @
a366373
此文件类型无法预览
RFID_PuYue_Debug/bin/Debug/RFID_HiStation_Debug.pdb
查看文件 @
a366373
此文件类型无法预览
RFID_PuYue_Debug/obj/Debug/RFID_HiStation_Debug.exe
查看文件 @
a366373
此文件类型无法预览
RFID_PuYue_Debug/obj/Debug/RFID_HiStation_Debug.pdb
查看文件 @
a366373
此文件类型无法预览
RFID_PuYue_Debug/obj/Debug/RFID_PuYue_Debug.csproj.AssemblyReference.cache
查看文件 @
a366373
此文件类型无法预览
RFID_PuYue_Debug/obj/Debug/RFID_PuYue_Debug.csproj.GenerateResource.cache
查看文件 @
a366373
此文件类型无法预览
编写
预览
支持
Markdown
格式
附加文件
你添加了
0
人
到此讨论。请谨慎行事。
Finish editing this message first!
Cancel
请
注册
或
登录
后发表评论