Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

send #3

Open
wants to merge 65 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
65 commits
Select commit Hold shift + click to select a range
d9170c8
renxiaoqi
renwangwang Oct 15, 2017
6dd3280
renxiaoqi
renwangwang Oct 15, 2017
c4ec32e
windows串口通信
Cartisia Oct 16, 2017
76877af
renxiaoqi
renwangwang Oct 16, 2017
014da14
0+格式模拟数据
Cartisia Oct 17, 2017
8158192
Create ways to do
Cartisia Oct 17, 2017
a593c5d
test data and response properly
Cartisia Oct 18, 2017
9cf1844
test data and response (modify)
Cartisia Oct 18, 2017
aa85204
Update 0+ virtual data.txt
renwangwang Oct 20, 2017
f9f89f0
Update 1+ virtual data
renwangwang Oct 20, 2017
2b39688
senddata
renwangwang Oct 20, 2017
0230141
zuoye
wjy3326 Oct 20, 2017
8b7459a
Delete senddata.ino
renwangwang Oct 20, 2017
78e5e76
renxiaoqi
renwangwang Oct 20, 2017
684826a
Update 1+ virtual data
wjy3326 Oct 21, 2017
512c005
Add files via upload
wjy3326 Oct 21, 2017
191f174
Update 输入输出练习.ino
wjy3326 Oct 21, 2017
0c74576
renxiaoqi
renwangwang Oct 23, 2017
752c37f
initial test doc
Cartisia Oct 23, 2017
7f43e4f
Add files via upload
wjy3326 Oct 23, 2017
f2908f3
Update Receive data and instructions
wjy3326 Oct 23, 2017
9a9e2d5
Update 1+ virtual data
wjy3326 Oct 23, 2017
037990a
Update Receive data to return information
wjy3326 Oct 23, 2017
b58e870
modify some mistakes and add dataSend
Cartisia Oct 24, 2017
20f4ad6
modify some mistakes and data send
Cartisia Oct 24, 2017
0df8451
modified
Cartisia Oct 24, 2017
1c78065
renxiaoqi
renwangwang Oct 24, 2017
b747460
renxiaoqi
renwangwang Oct 24, 2017
37fda59
modified send and receive parts
Cartisia Oct 24, 2017
50f58f1
sending and receiving parts are modified
Cartisia Oct 24, 2017
ef434be
sending and receiving parts are modified
Cartisia Oct 24, 2017
2d29a22
modify test doc
Cartisia Oct 24, 2017
7b3c978
data preprocess
Cartisia Oct 25, 2017
3f4ae13
自动生成数据
Cartisia Oct 25, 2017
4b00c09
Update canmsg-sample.txt
wjy3326 Oct 26, 2017
f07b80f
Update 1+ virtual data
wjy3326 Oct 26, 2017
b70b715
Add files via upload
wjy3326 Oct 26, 2017
c3a7aff
Add files via upload
wjy3326 Oct 26, 2017
908ec9a
Update 输入输出练习.ino
wjy3326 Oct 26, 2017
a741090
Create senddata3
wjy3326 Oct 26, 2017
e7ae7a6
测试数据又增强了一些
Cartisia Oct 26, 2017
e7f23b7
增强测试数据
Cartisia Oct 26, 2017
49a4826
生成错误数据
Cartisia Oct 26, 2017
b983975
解释各个版本生成的数据是用来测试什么
Cartisia Oct 26, 2017
bf7c9d1
data_v2 fix bug
Cartisia Oct 26, 2017
36ddcba
renxiaoqi
renwangwang Oct 29, 2017
2d7393a
update cantool code
renwangwang Oct 29, 2017
607ecee
update cantool code
renwangwang Oct 29, 2017
7c14f15
bug fix
Cartisia Oct 29, 2017
5e13d27
Merge remote-tracking branch 'refs/remotes/origin/ourproject' into ou…
Cartisia Oct 29, 2017
8d4209b
Add files via upload
wjy3326 Oct 29, 2017
2bfdd27
Update 输入输出练习.ino
wjy3326 Oct 29, 2017
a253bdb
Update cantool updated finally
wjy3326 Oct 29, 2017
f8c08b1
Update cantool updated finally
wjy3326 Oct 29, 2017
19653cc
Add files via upload
wjy3326 Oct 29, 2017
4816eeb
Update cantool updated finally
wjy3326 Oct 29, 2017
338cecf
Update cantool updated finally
wjy3326 Oct 29, 2017
4db4cf1
Add files via upload
Cartisia Oct 29, 2017
f2e096f
Add files via upload
Cartisia Oct 29, 2017
e6d79e4
Add files via upload
Cartisia Oct 29, 2017
105ae8e
Add files via upload
Cartisia Oct 29, 2017
10cf542
Delete windows app.docx
Cartisia Oct 29, 2017
ab3697f
Delete 主要存在的问题_v1.docx
Cartisia Oct 29, 2017
bf1f271
代码打包
Cartisia Oct 30, 2017
026abd5
Merge remote-tracking branch 'refs/remotes/origin/ourproject' into ou…
Cartisia Oct 30, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions 0+ virtual data.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
t358(856) 8 CD3CFC7F1818F000
t3D(61) 8 2A00000000000000
t42B(1067) 8 7F37FF0000000000
t420(1056) 8 FF37FF0000000000
t318(792) 8 0200000000000000
t345(837) 8 0000000024000000
t393(915) 8 00000F0F33000000
t320(800) 8 F9FFFFEF0FC79EFF
t321(801) 8 FFFF0C0F000F2000
t31D(797) 8 0700000000000000
t360(864) 8 050F0F0FFF000000
t363(867) 8 0F03C00F7F00F0F7
t364(868) 8 CE60800700000000



19 changes: 19 additions & 0 deletions 1+ virtual data
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
605(1541) 6 000000000000
601(1537) 8 0000000000000000
607(1543) 8 0000000000000000
606(1542) 8 0000000000000000
604(1540) 6 000000000000
41D(1053) 4 00000000
41C(1052) 4 00000000
41B(1051) 4 00000000
41A(1050) 4 00000000
1a0(416) 4 00000000
100(256) 8 0000000000000000
1F1(497) 1 40
1F0(496) 1 20
1A1(417) 2 0100
111(273) 8 00FF000000000F00




5 changes: 5 additions & 0 deletions CanToolRequirment
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
1.根据CAN信号Signal描述数据库”格式创造虚拟数据
2. 将创造好的虚拟数据传输给CanTool App
3. 接收CanTool App发送的数据返回结果
4. 解析APP发过来的命令,执行命令,返回结果

154 changes: 154 additions & 0 deletions Receive data and instructions
Original file line number Diff line number Diff line change
@@ -0,0 +1,154 @@
String input = "";
boolean flag = false;
int state = 0; //表示open的状态int state=0;
void setup() {
// put your setup code here, to run once:
Serial.begin(115200);
}

void loop() {
// put your main code here, to run repeatedly:
if (flag)
{
// Serial.println(input);
dataProcess(input);
input="";
flag=false;
}
}
void serialEvent()
{
while (Serial.available())
{
char inChar=(char)Serial.read();
input+=inChar;
if (inChar=='\r')
{
flag=true;
}
}
}
void dataProcess(String command)
{
if(command==NULL||command.length()==0)
sendData(0);
char type=command.charAt(0);
command = command.substring(0,command.length()-1);
if(type=='V'&&command.length()==1)
{
sendData(1);

}
else if(type=='O'&&command.charAt(1)=='1'&&command.length()==2)
{
open();
}
else if(type=='C'&&command.length()==1)
{
close();
}
else if(type=='S'&&command.length()==2)
{
setSpeed(command.charAt(1));
}
else if(type=='T' || type=='t')
{
sendFrameData(command,type);
}
else
{
sendData(0);
}
}

void sendFrameData(String data,char type)
{
int normal;
if(state == 1)
{
sendData(0);
return;
}
if(type == 'T')
normal = 10;
else
normal = 5;

int len = data.length();
for(int i = 1; i < len; i++)
{
if(!((data[i] >= '0'&& data[i] <= '9') || ( data[i] >= 'A'&&data[i] <= 'F')))

{
sendData(0);
return;
}

}
int canLen = data.charAt(4)-'0';
if(len < normal || canLen <= 0 || canLen >8 || len != normal + canLen*2)
{
sendData(0);
return;
}
sendData(1);
}
void setSpeed(char c)
{
if(state==0)
{
int level=(int)(c-'0');
if(level<0||level >8)
sendData(0);
else
{
sendData(1);
}
}
else
{
sendData(0);
}
}
void close()
{
if(state==1)
{
state=0;
sendData(1);
}
else
{
sendData(0);
}
}
void open()
{
if(state==0)
{
state=1;
sendData(1);
}
else
{
sendData(0);
}
}
void sendData(int flag)
{
if(flag == 0){
Serial.write((char)7);
Serial.println("bhjdscvsdjc");}
else
{
Serial.print("SV2.5-HV2.0");
Serial.write("\r");
}
}







147 changes: 147 additions & 0 deletions Receive data to return information
Original file line number Diff line number Diff line change
@@ -0,0 +1,147 @@
String comdata = "";
int correct = 0; //表示数据正确与否
int on = 0; //表示open的状态

void setup() {
// put your setup code here, to run once:
Serial.begin(115200);

}
void loop() {
// put your main code here, to run repeatedly:
while(Serial.available() > 0)
{
char sig = char(Serial.read());
comdata += sig;
delay(2);
if(sig == '\r')
{
correct = 1;
}

}

if(correct == 1)
{
dataProcess(comdata);
comdata = "";
correct = 0;
}

}


void dataProcess(String data)
{
if(data == NULL)
sendData(0);
char type = data.charAt(0);
data = data.substring(0,data.length()-1);
if(type == 'V' && data.length() == 1)
{
Serial.println("SV2.5-HV2");
return;
}

else if(type == 'O' && data.charAt(1)=='1'&&data.length()==2)
open();
else if(type=='C'&&data.length()==1)
close();
else if(type=='S'&&data.length()==2)
setSpeed(data.charAt(1));
if(type=='T' || type=='t')
sendFrameData(data,type);
else
sendData(0);
}
void setSpeed(char c)
{
if(on==0)
{
int level=(int)(c-'0');
if(level<0||level >8)
sendData(0);
else
{
sendData(1);
}
}
else
{
sendData(0);
}
}
void close()
{
if(on==1)
{
on=0;
sendData(1);
}
else
{
sendData(0);
}
}
void open()
{
if(on==0)
{
on=1;
sendData(1);
}
else
{
sendData(0);
}
}
void sendFrameData(String data,char type)
{
int normal;
if(on == 1)
{
sendData(0);
return;
}
if(type == 'T')
normal = 10;
else
normal = 5;

int len = data.length();
for(int i = 1; i < len; i++)
{
if(!((data[i] >= '0'&& data[i] <= '9') || ( data[i] >= 'A'&&data[i] <= 'F')))

{
sendData(0);
return;
}

}
int canLen = data.charAt(4)-'0';
if(len < normal || canLen <= 0 || canLen >8 || len != normal + canLen*2)
{
sendData(0);
return;
}
sendData(1);
}

void sendData(int sig)
{
if(sig == 0){
Serial.write((char)7);
Serial.println("no");
}
else{
Serial.println("ok");
Serial.write("\r");
}

}





Loading