Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
UCC
OpenDispense2
Commits
cfcb64f0
Commit
cfcb64f0
authored
Apr 17, 2015
by
John Hodge
Browse files
Server/Coke - Improved logging
parent
6b70240e
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/server/handler_coke.c
View file @
cfcb64f0
...
...
@@ -48,12 +48,14 @@ tHandler gCoke_Handler = {
Coke_CanDispense
,
Coke_DoDispense
};
// - Config
const
char
*
gsCoke_ModbusAddress
=
"130.95.13.73"
;
int
giCoke_ModbusPort
=
502
;
bool
gbCoke_DummyMode
=
false
;
// - State
modbus_t
*
gCoke_Modbus
;
time_t
gtCoke_LastDispenseTime
;
time_t
gtCoke_LastReconnectTime
;
bool
gbCoke_DummyMode
=
1
;
int
giCoke_NextCokeSlot
=
0
;
// == CODE ===
...
...
@@ -118,8 +120,12 @@ int Coke_DoDispense(int UNUSED(User), int Item)
int
Coke_int_ConnectToPLC
(
void
)
{
// Ratelimit
if
(
time
(
NULL
)
-
gtCoke_LastReconnectTime
<
COKE_RECONNECT_RATELIMIT
)
time_t
elapsed
=
time
(
NULL
)
-
gtCoke_LastReconnectTime
;
if
(
elapsed
<
COKE_RECONNECT_RATELIMIT
)
{
Debug_Notice
(
"Not reconnecting, only %llis have pased, %i limit"
,
(
long
long
)
elapsed
,
COKE_RECONNECT_RATELIMIT
);
errno
=
EAGAIN
;
return
-
1
;
}
if
(
!
gCoke_Modbus
)
{
...
...
@@ -135,7 +141,7 @@ int Coke_int_ConnectToPLC(void)
// Preven resource leaks
modbus_close
(
gCoke_Modbus
);
}
Debug_Notice
(
"Connecting to coke PLC machine on '%s'
\n
"
,
gsCoke_ModbusAddress
);
Debug_Notice
(
"Connecting to coke PLC machine on '%s'
:%i
"
,
gsCoke_ModbusAddress
,
giCoke_ModbusPort
);
if
(
modbus_connect
(
gCoke_Modbus
)
)
{
...
...
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