Question
Hi I am struggeling with this program on IPC. For this task you will have to write a C/C++ program that simulates an IoT (Internet
Hi I am struggeling with this program on IPC.
For this task you will have to write a C/C++ program that simulates an IoT (Internet of Things) controller. Any number of IoT devices can connect to this controller and report their status. The controller will thus have a complete picture of all the IoT devices that have reported to it, the current status of those devices and when last the status changed/updated. To simulate the messages sent by the various IoT devices, a text file called device data.txt is provided that contains a number of device messages sent, with each line representing a distinct message. Each message contains a device name, a status value and a Unix epoch value which are separated by commas. Your C/C++ program will read this file line by line and sent the contained message to a new child process. The child process will separate the message into device name, status value and epoch value, convert the epoch to a date and time string and send the data back to the parent process. The parent process will use this data to create and maintain a IoT device list with associated status value and time. Implementation The following steps show how your program should work: 1. Your program opens the provided IoT device data input file. 2. It then reads the input file line by line. 3. For each input line, it creates a new child process with the fork() function. 4. The parent process then sends the input line to the child process via a pipe. 5. The child process transforms the input line to data values and sends them back to the parent via a pipe. 6. The parent process uses the received data to update an IoT devices status list. 7. When the reading of the input file is complete, the program prints the final IoT devices status list.
Example output!
the text file :
FrontDoor,Closed,1532700000 LivingLight,Off,1532700000 LivingTemp,19,1532700000 LivingTemp,18.5,1532703600 FrontDoor,Open,1532707200 LivingTemp,18,1532707200 LivingLight,On,1532707203 FrontDoor,Closed,1532707205 LivingTemp,18.1,1532710800
Parent sent file linet8 Child received message line: FrontDoor,Closed,1532707205 Child sent device: FrontDoorr Child sent value: Closed Child sent time: 18:00: 05 27/07/2018 Parent received update for FrontDoor: Closed at 18:00:05 27/07/2018 Parent sent file line 9 Child received message line: LivingTemp,18.1,1532710800 Child sent device: LivingTemp Child sent value: Child sent time: 19:00:00 27/07/2018 Parent received update for LivingTemp: 18.1 at 19:00:00 27/07/2018 18.1 Device List: FrontDoor LivingLight: LivinqTemp: Closed 18:00:05 27/07/2018 @ 18:00:03 27/07/2018 18.1 19:00:00 27/07/2018Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started