Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
axel.maurer
bwCard Reader
Commits
2a82fe37
Commit
2a82fe37
authored
Aug 20, 2021
by
axel.maurer
Browse files
function 14 - 16 changed to string
parent
4343409a
Changes
1
Hide whitespace changes
Inline
Side-by-side
KIT-Card.c
View file @
2a82fe37
...
...
@@ -1015,8 +1015,8 @@ int DoDesFireCardAction(int action, char *parmStr, char *resultStr)
int
position
;
int
opCode
;
int
count
;
int
actSeconds
;
int
cardSeconds
;
int
actSeconds
=
0
;
int
cardSeconds
=
0
;
char
cardKeyStr
[
50
];
switch
(
action
)
...
...
@@ -1075,19 +1075,18 @@ int DoDesFireCardAction(int action, char *parmStr, char *resultStr)
sprintf
(
mBuffer
,
"cardNumber read: bwCardNumber=%s, bufferLen=%d"
,
bwCardNumber
,
bufferLen
);
PrintLnDebug
(
mBuffer
);
//File 1 lesen, wenn er existiert
//File 1 lesen, wenn er existiert und in outBufferStr speichern
if
(
CheckForAppFile
(
appId
,
1
)){
if
(
!
ReadDesFireCardAppFile
(
appId
,
1
,
byteBuffer
,
&
bufferLen
,
8
,
0
,
AUTH_KEY_READ
,
resultStr
)){
if
(
!
ReadDesFireCardAppFile
(
appId
,
1
,
byteBuffer
,
&
bufferLen
,
0x40
,
0
,
AUTH_KEY_READ
,
resultStr
)){
sprintf
(
mBuffer
,
"291,Error reading file1 of bwcard"
);
PrintLnDebug
(
mBuffer
);
sprintf
(
resultStr
,
"%s"
,
mBuffer
);
return
(
false
);
}
CopyBytes
((
byte
*
)
&
actSeconds
,
byteBuffer
,
4
);
CopyBytes
((
byte
*
)
&
cardSeconds
,(
byte
*
)
(
byteBuffer
+
4
),
4
);
sprintf
(
mBuffer
,
"actSeconds=%x,cardSeconds=%x"
,
actSeconds
,
cardSeconds
);
sprintf
(
mBuffer
,
"File read:%s"
,(
char
*
)
byteBuffer
);
PrintLnDebug
(
mBuffer
);
sprintf
(
outBufferStr
,
"%s"
,(
char
*
)
byteBuffer
);
}
else
{
sprintf
(
mBuffer
,
"No Appfile 1 for 0x%x found"
,
appId
);
PrintLnDebug
(
mBuffer
);
...
...
@@ -1129,21 +1128,18 @@ int DoDesFireCardAction(int action, char *parmStr, char *resultStr)
sprintf
(
resultStr
,
"%s"
,
bwCardNumber
);
break
;
case
ACTION_BWCARD_OLD_READ_NUMBER_FILE_1
:
sprintf
(
resultStr
,
"%s;%
x;%x
"
,
bwCardNumber
,
actSeconds
,
cardSeconds
);
sprintf
(
resultStr
,
"%s;%
s
"
,
bwCardNumber
,
outBufferStr
);
break
;
case
ACTION_BWCARD_OLD_UID_READ_NUMBER_FILE_1
:
sprintf
(
resultStr
,
"%s;%
x;%x
"
,
cardUid
,
actSeconds
,
cardSeconds
);
sprintf
(
resultStr
,
"%s;%
s
"
,
cardUid
,
outBufferStr
);
break
;
case
ACTION_BWCARD_OLD_WRITE_FILE_1
:
// size of time in seconds on card (int)
count
=
4
;
fileId
=
1
;
// Hex representation = 2* count
actSeconds
=
HexStr2Int
(
parmStr
,
count
*
2
);
cardSeconds
=
HexStr2Int
((
char
*
)(
parmStr
+
(
count
*
2
)),
count
*
2
);
CopyBytes
(
appFileBuffer
,
(
byte
*
)
&
actSeconds
,
count
);
CopyBytes
((
byte
*
)(
appFileBuffer
+
count
),
(
byte
*
)
&
cardSeconds
,
count
);
sprintf
(
mBuffer
,
"becaad fil1 data write cardSeconds=%d, actSeconds=%d, parmStr= %s"
,
cardSeconds
,
actSeconds
,
parmStr
);
appFileBufferLen
=
MIN
(
strlen
(
parmStr
),
0x40
);
CopyBytes
(
appFileBuffer
,
(
byte
*
)
parmStr
,
appFileBufferLen
);
sprintf
(
mBuffer
,
"data write appId=0x%x, fileId=%d, appFileBuffer= %s appFileBufferLen=%d, parmStr= %s"
,
appId
,
fileId
,
(
char
*
)
appFileBuffer
,
appFileBufferLen
,
parmStr
);
PrintLnDebug
(
mBuffer
);
openedAppGlobal
=
CLOSED_APP
;
...
...
@@ -1153,7 +1149,21 @@ int DoDesFireCardAction(int action, char *parmStr, char *resultStr)
return
(
false
);
}
if
(
!
CheckForAppFile
(
appId
,
fileId
))
if
(
CheckForAppFile
(
appId
,
fileId
))
// delete old data
{
openedAppGlobal
=
CLOSED_APP
;
bufferLen
=
0x40
;
FillBytes
(
byteBuffer
,
0
,
bufferLen
);
if
(
!
WriteDesFireCardAppFile
(
appId
,
fileId
,
byteBuffer
,
bufferLen
,
0
,
AUTH_KEY_WRITE
,
resultStr
))
{
sprintf
(
mBuffer
,
"Error WriteDesFireCardAppFile for clear: %s"
,
resultStr
);
PrintLnDebug
(
mBuffer
);
sprintf
(
resultStr
,
"753, %s"
,
mBuffer
);
return
(
false
);
}
}
else
{
// force reopen App
openedAppGlobal
=
CLOSED_APP
;
...
...
@@ -1165,7 +1175,7 @@ int DoDesFireCardAction(int action, char *parmStr, char *resultStr)
}
}
openedAppGlobal
=
CLOSED_APP
;
if
(
!
WriteDesFireCardAppFile
(
appId
,
fileId
,
appFileBuffer
,
count
*
2
,
0
,
AUTH_KEY_WRITE
,
resultStr
))
if
(
!
WriteDesFireCardAppFile
(
appId
,
fileId
,
appFileBuffer
,
appFileBufferLen
,
0
,
AUTH_KEY_WRITE
,
resultStr
))
{
sprintf
(
mBuffer
,
"Error WriteDesFireCardAppFile: %s"
,
resultStr
);
PrintLnDebug
(
mBuffer
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment