Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
FS-ELAB
pilc2server_old
Commits
a6782def
Commit
a6782def
authored
Jan 24, 2022
by
Joshua Supra
Browse files
test
parent
71bffb95
Changes
1
Hide whitespace changes
Inline
Side-by-side
main.c
View file @
a6782def
...
...
@@ -28,7 +28,8 @@ int main (int argc, char *argv[]){
initContCounterDone
=
0
;
zmq_data
*
zmq_recive_data
[
2
];
int
NrOfBytesReceived
[
2
];
//NrOfBytesReceived[0] = -1;
pilcIOGpioStruct
PilcIoGpios
;
STOP
=
false
;
...
...
@@ -63,18 +64,15 @@ int main (int argc, char *argv[]){
while
(
1
)
{
zmq_r
ecive
_data
[
0
]
->
NrOfBytes
=
zmq_recv
(
client_responder
,
NrOfBytesR
ec
e
ive
d
[
0
]
=
zmq_recv
(
client_responder
,
zmq_recive_data
[
0
]
->
data
,
255
,
ZMQ_DONTWAIT
);
zmq_recive_data
[
0
]
->
socket
=
client_responder
;
if
(
zmq_recive_data
[
0
]
->
NrOfBytes
!=
-
1
)
{
//printf("1\n");
printf
(
"%i
\n
"
,
&
zmq_recive_data
[
0
]
->
NrOfBytes
);
printf
(
"%i
\n
"
,
zmq_recive_data
[
0
]
->
NrOfBytes
);
if
(
NrOfBytesReceived
[
0
]
!=
-
1
)
{
zmq_recive_data
[
0
]
->
NrOfBytes
=
NrOfBytesReceived
[
0
];
pthread_mutex_lock
(
&
lock
);
pthread_create
(
&
thread_network
[
0
],
NULL
,
network
,
(
void
*
)
zmq_recive_data
[
0
]);
pthread_create
(
&
thread_network
[
0
],
NULL
,
network
,
(
void
*
)
zmq_recive_data
[
0
]);
pthread_mutex_unlock
(
&
lock
);
}
else
{
break
;
...
...
@@ -82,18 +80,17 @@ int main (int argc, char *argv[]){
}
while
(
1
)
{
zmq_recive_data
[
1
]
->
NrOfBytes
=
zmq_recv
(
gui_responder
,
zmq_recive_data
[
1
]
->
data
,
255
,
ZMQ_DONTWAIT
);
printf
(
"bla
\n
"
);
// NrOfBytesReceived[0] = -1;
NrOfBytesReceived
[
1
]
=
zmq_recv
(
gui_responder
,
zmq_recive_data
[
1
]
->
data
,
255
,
ZMQ_DONTWAIT
);
zmq_recive_data
[
1
]
->
socket
=
gui_responder
;
if
(
zmq_r
ecive
_data
[
1
]
->
NrOfBytes
!=
-
1
)
{
if
(
NrOfBytesR
ec
e
ive
d
[
1
]
!=
-
1
)
{
//printf("2\n");
zmq_recive_data
[
1
]
->
NrOfBytes
=
NrOfBytesReceived
[
1
];
pthread_mutex_lock
(
&
lock
);
pthread_create
(
&
thread_network
[
1
],
NULL
,
network
,
(
void
*
)
zmq_recive_data
[
1
]);
//pthread_detach(thread_network[1]);
pthread_mutex_unlock
(
&
lock
);
}
...
...
@@ -105,10 +102,11 @@ int main (int argc, char *argv[]){
if
(
front_LED_update_ctr
==
0
)
{
pthread_create
(
&
thread_led_update
,
NULL
,
updateIOLeds
,
(
void
*
)
IOCards
);
//pthread_detach(thread_led_update);
front_LED_update_ctr
=
20
;
}
pthread_join
(
thread_network
[
0
],
NULL
);
pthread_join
(
thread_network
[
1
],
NULL
);
pthread_join
(
thread_led_update
,
NULL
);
...
...
@@ -152,7 +150,7 @@ void *network(void *args){
command
=
zmq_rec_data
->
data
[
0
];
//printf("command: %.8x\n", command);
nbytes
=
zmq_rec_data
->
NrOfBytes
;
printf
(
"%i
\n
"
,
&
zmq_rec_data
->
NrOfBytes
);
//
printf("%i\n", &zmq_rec_data->NrOfBytes);
switch
(
command
){
case
0x0
:
status
=
RegtoNetwork
(
zmq_rec_data
);
break
;
case
0x1
:
status
=
NetworktoReg
(
zmq_rec_data
);
break
;
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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