diff --git a/detect.h b/detect.h index 3b56a2c..9d20ccf 100644 --- a/detect.h +++ b/detect.h @@ -63,8 +63,8 @@ class PosCtl { void CalibModeAxis(int x, int y); void CalibModeFinish(); - void OutputClose(); - void OutputOpen(); + int OutputClose(); + int OutputOpen(); public: PosCtl(); ~PosCtl() {}; @@ -95,9 +95,9 @@ class PosCtl { std::string GetDevice() { return device; }; void Loop (int posx, int posy); - void OutputWriteValue (int axis, double value); - void OutputWriteStop (int axis); - void OutputWriteStart (int axis); + int OutputWriteValue (int axis, double value); + int OutputWriteStop (int axis); + int OutputWriteStart (int axis); }; diff --git a/posctl.cc b/posctl.cc index 5c909da..449daa4 100644 --- a/posctl.cc +++ b/posctl.cc @@ -606,16 +606,18 @@ void PosCtl::SetDevice (std::string d) { }; -void PosCtl::OutputClose() { +int PosCtl::OutputClose() { printf ("%s:%d %s\n", __FILE__, __LINE__, __FUNCTION__); if (device_fd > 0) close(device_fd); device_fd = -1; + + return 0; }; -void PosCtl::OutputOpen() { +int PosCtl::OutputOpen() { printf ("%s:%d %s\n", __FILE__, __LINE__, __FUNCTION__); - if (device_fd > 0) return; + if (device_fd > 0) return 0; device_fd = open (device.c_str(), O_RDWR); if (device_fd < 0) { @@ -623,16 +625,18 @@ void PosCtl::OutputOpen() { device.c_str(), strerror(errno)); errormessage_display ((char *)"window-posctl", (char *)"OutputOpen", (char*)"%s:%d could not open device:%s Error:%s\n", __FILE__, __LINE__, device.c_str(), strerror(errno)); + return -1; } + return 0; }; -void PosCtl::OutputWriteValue (int axis, double value) { +int PosCtl::OutputWriteValue (int axis, double value) { char outbuf[255]; ssize_t len; printf ("%s:%d %s Axis %d Value:%f\n", __FILE__, __LINE__, __FUNCTION__, axis, value); - if (device_fd <= 0) OutputOpen(); + if (device_fd <= 0) if (OutputOpen() != 0) return -1; // // save language setting and set to plain C @@ -654,21 +658,25 @@ void PosCtl::OutputWriteValue (int axis, double value) { printf ("%s:%d could not write data to device:%s Error:%s\n", __FILE__, __LINE__, device.c_str(), strerror(errno)); errormessage_display ((char *)"window-posctl", (char *)"OutputWriteValue", - "%s:%d could not write data to device:%s Error:%s\n", __FILE__, __LINE__, + (char *) "%s:%d could not write data to device:%s Error:%s\n", __FILE__, __LINE__, device.c_str(), strerror(errno)); } + + return 0; }; -void PosCtl::OutputWriteStop (int axis) { +int PosCtl::OutputWriteStop (int axis) { printf ("%s:%d %s Axis %d\n", __FILE__, __LINE__, __FUNCTION__, axis); - if (device_fd <= 0) OutputOpen(); + if (device_fd <= 0) if (OutputOpen() != 0) return -1; + return 0; } -void PosCtl::OutputWriteStart (int axis) { +int PosCtl::OutputWriteStart (int axis) { printf ("%s:%d %s Axis %d\n", __FILE__, __LINE__, __FUNCTION__, axis); - if (device_fd <= 0) OutputOpen(); + if (device_fd <= 0) if (OutputOpen() != 0) return -1; + return 0; }