| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546 |
- #include <QCoreApplication>
- #include "dogcore.h"
- #include "datacollector.h"
- DataCollectorShm *dataColShm;
- SmokerDeviceSensorList *smokerDeviceList;
- bool load_shm()
- {
- key_t key;
- int shmid;
- if((key = ftok(SHM_PATH,static_cast<int>(SHM_PORT))) == -1){
- return false;
- }
- if((shmid = shmget(key,sizeof(DataCollectorShm),IPC_CREAT|0666))==-1){
- return false;
- }
- printf("shmid1: %d\n",shmid);
- dataColShm = static_cast<DataCollectorShm *>(shmat(shmid,nullptr,0));
- if((key = ftok(SHM_DEVPATH,static_cast<int>(SHM_DEVPORT))) == -1){
- return false;
- }
- printf("shmid11: %d\n",shmid);
- if((shmid = shmget(key,sizeof(SmokerDeviceSensorList),IPC_CREAT|0666))==-1){
- return false;
- }
- printf("shmid2: %d\n",shmid);
- smokerDeviceList = static_cast<SmokerDeviceSensorList *>(shmat(shmid,nullptr,0));
- return true;
- }
- int main(int argc, char *argv[])
- {
- QCoreApplication a(argc, argv);
- if(load_shm()){
- DogCore *dogcore = new DogCore(nullptr);
- dogcore->start();
- }else{
- exit(1);
- }
- return a.exec();
- }
|