Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
S
systemprogramming project team 11
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
김가을
systemprogramming project team 11
Commits
09f97daf
Commit
09f97daf
authored
1 year ago
by
이종현
Browse files
Options
Downloads
Patches
Plain Diff
Add new file
parent
cf7ed066
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
camer_client.c
+63
-0
63 additions, 0 deletions
camer_client.c
with
63 additions
and
0 deletions
camer_client.c
0 → 100644
+
63
−
0
View file @
09f97daf
#include
<stdio.h>
#include
<string.h>
#include
<stdlib.h>
#include
<unistd.h>
#include
<pthread.h>
#include
<fcntl.h>
#include
<linux/spi/spidev.h>
#include
<linux/types.h>
#include
<stdint.h>
#include
<sys/ioctl.h>
#include
<arpa/inet.h>
#include
<netinet/in.h>
#include
<sys/socket.h>
int
sock
;
void
error_handling
(
const
char
*
message
,
int
sock
)
{
close
(
sock
);
perror
(
message
);
fputc
(
'\n'
,
stderr
);
exit
(
1
);
}
int
main
(
int
argc
,
char
*
argv
[])
{
struct
sockaddr_in
server_addr
;
char
picture
;
ssize_t
read_stat
;
if
(
argc
!=
3
)
{
printf
(
"Please deliver IP & Port num as arguments Correctly!
\n
"
);
exit
(
1
);
}
sock
=
socket
(
PF_INET
,
SOCK_STREAM
,
0
);
if
(
sock
==
-
1
)
error_handling
(
"socket() error"
,
sock
);
memset
(
&
server_addr
,
0
,
sizeof
(
server_addr
));
server_addr
.
sin_family
=
AF_INET
;
server_addr
.
sin_addr
.
s_addr
=
inet_addr
(
argv
[
1
]);
server_addr
.
sin_port
=
htons
(
atoi
(
argv
[
2
]));
if
(
connect
(
sock
,
(
struct
sockaddr
*
)
&
server_addr
,
sizeof
(
server_addr
))
==
-
1
)
error_handling
(
"connect() error"
,
sock
);
while
(
1
)
{
read_stat
=
read
(
sock
,
&
picture
,
1
);
if
(
read_stat
==
-
1
)
{
perror
(
"Client Output; reading data from socket error"
);
exit
(
1
);
}
else
if
(
read_stat
==
0
)
{
break
;
}
else
{
if
(
!
strncmp
(
&
picture
,
"1"
,
1
))
{
system
(
"raspistill -o image.jpg"
);
sleep
(
1
);
system
(
"python3 send_email2.py"
);
}
}
}
return
0
;
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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!
Save comment
Cancel
Please
register
or
sign in
to comment