x64_Linux_GCC processEvents trouble

Posted in General by Chipp Jansen Fri Feb 16 2018 17:39:15 GMT+0000 (Coordinated Universal Time)·3·Viewed 319 times

Hello - I'm trying to write a simple Linux GCC tool to dump the events using the ISKN API. I have a small program compiling and running with the libISKN_API.so library, and it connects to the Slate 2. However, the processEvent function implemented with the Listener gets called *very* infrequently, and only after intense tapping on the Slate with the stylus. It also is called with exact same timecode and event Type ("Pen3D"). My code is based off of the MagicBeep code, but I have reduced it to what I hope is the simpliest program --- main.cpp --- #include <stdio.h> #include <stdlib.h> #include "ISKN_API.h" #include "SlateListener.h" using namespace ISKN_API; using namespace std; int main (int argc, char *argv[]) { SlateListener *sl = new SlateListener(); while(1) { } return 0; } --- SlateListener.h --- #ifndef SLATELISTENER_H #define SLATELISTENER_H #include "ISKN_API.h" #include <iostream> using namespace ISKN_API; using namespace std; class SlateListener : public ISKN_API::Listener { public: // ISKN API attributes SlateManager *iskn_SlateManager; Device *iskn_Device; //Constructor SlateListener(); ~SlateListener(); //Inherited methods void processEvent(Event &e, unsigned int timecode); void connectionStatusChanged(bool connected); }; #endif // SLATELISTENER_H --- SlateListener.cpp --- #include "SlateListener.h" SlateListener::SlateListener() { // Create SlateManager and Device iskn_SlateManager = new SlateManager(); iskn_Device = &iskn_SlateManager->getDevice(); // Register events Listener iskn_SlateManager->registerListener(this); // Connect to the Slate cout << "Attempting to connect to ISKN Slate ..." << endl; iskn_SlateManager->connect(); } void SlateListener::connectionStatusChanged(bool connected) { try { if (connected) { iskn_SlateManager->subscribe(AUTO_ALL); cout << "Slate connected!" << endl; } else { cout << "Slate could not connect!" << endl; } } catch (Error &err) { // wcout << err.Message() << endl; cout << "Error Code " << err.Code << endl; } } void SlateListener::processEvent(Event &e, unsigned int timecode) { cout << "processEvent " << timecode << " " << e.Type << endl; } SlateListener::~SlateListener() { } My goal is to just output all of the events. Any help or insight into the ISKN_API library for linux would be greatly appreciated!!! Thanks!
Feb 16, 2018

Sorry, the formatting of the code is terrible! Here is a better formatted version of the code in Markdown

main.cpp

  #include <stdio.h>
  #include <stdlib.h>

  #include "ISKN_API.h"
  #include "SlateListener.h"

  using namespace ISKN_API;
  using namespace std;

  int main (int argc, char *argv[])
  {
    SlateListener *sl = new SlateListener();

    while(1) { }

    return 0;
  }

SlateListener.h

  #ifndef SLATELISTENER_H
  #define SLATELISTENER_H

  #include "ISKN_API.h"
  #include <iostream>

  using namespace ISKN_API;
  using namespace std;

  class SlateListener : public ISKN_API::Listener
  {
  public:
      // ISKN API attributes
      SlateManager   *iskn_SlateManager;
      Device      *iskn_Device;

      //Constructor
      SlateListener();
      ~SlateListener();

      //Inherited methods
      void processEvent(Event &e, unsigned int timecode);
      void connectionStatusChanged(bool connected);
  };

  #endif // SLATELISTENER_H

SlateListener.cpp

  #include "SlateListener.h"

  SlateListener::SlateListener()
  {
      // Create SlateManager and Device
      iskn_SlateManager  = new SlateManager();
      iskn_Device     = &iskn_SlateManager->getDevice();

      // Register events Listener
      iskn_SlateManager->registerListener(this);

      // Connect to the Slate
      cout << "Attempting to connect to ISKN Slate ..." << endl;
      iskn_SlateManager->connect();
  }

  void SlateListener::connectionStatusChanged(bool connected)
  {
      try
      {
          if (connected)
          {
              iskn_SlateManager->subscribe(AUTO_ALL);

              cout << "Slate connected!" << endl;
          }
          else
          {
              cout << "Slate could not connect!" << endl;
          }
      }
      catch (Error &err)
      {
          // wcout << err.Message() << endl;
          cout << "Error Code " << err.Code << endl;
      }
  }


  void SlateListener::processEvent(Event &e, unsigned int timecode)
  {
    cout << "processEvent " << timecode << " " << e.Type << endl;
  }

  SlateListener::~SlateListener()
  {
  }
Feb 20, 2018

Hi Chipp Jansen,

You are having wrong results because you try to subscribe to all the events at a time by using AUTO_ALL as a subscription parameter : iskn_SlateManager->subscribe(AUTO_ALL).

In fact when you use AUTO_ALL, the Slate will send a huge amount of data. The API can not process it so you’re getting a weird behaviour.
We strongly recommend you not to use AUTO_ALL at all. It’s not mentioned in the API documentation that is true.

Be aware that AUTO_PEN_2D and AUTO_PEN_3D events have redundant data. If you subscribe to both of them you'll receive the X,Y position , orientation and contact twice.The only difference between the 2 events is the Z position , thats why we call it AUTO_PEN_3D.
So if you only need the X,Y position of the pen tip you have to subscribe to AUTO_PEN_3D. If you need more you can use AUTO_PEN_3D. In case you need the position and the orientation of the magnet ( the pen Ring ) you can use AUTO_OBJECT_3D.

For exemple you can use that as subscription :

iskn_SlateManager->subscribe(
AUTO_STATUS |
AUTO_SOFTWARE_EVENTS |
AUTO_HARDWARE_EVENTS |
AUTO_PEN_2D
) ;

In this exemple we ask the Slate to send data about the battery ( AUTO_STATUS ), about the magnet detection (AUTO_SOFTWARE_EVENTS), about the Slate buttons ( AUTO_HARDWARE_EVENTS ) and about the pen tip position AUTO_PEN_2D.

We are actually working on a new versions for the API and the documentation. The update is scheduled for April.

We will keep you informed as development progress. In the meantime we recommend you not use AUTO_ALL nor AUTO_ACCELEROMETER events because there are not supported anymore.

Feel free to contact as if you have others questions or comments.

Rabeb for inks team.

Feb 22, 2018

Thanks Rabeb for the info on which subscriber flags are working. I tried AUTO_STATUS, AUTO_SOFTWARE_EVENTS, AUTO_HARDWARE_EVENTS, and AUTO_PEN_2D.

I have been able to see AUTO_STATUS, AUTO_SOFTWARE_EVENTS, and AUTO_PEN_2D events for the first 5 seconds of running with the device. The HANDSHAKES do not begin until I move the Pen over the Slate for a little bit. After about 5 seconds, the events stop running. Looking at the USB port traffic in wireshark, it appears that the device is still sending information, but perhaps a buffer filled up in the library.

One thing that I noticed was that the timecode does not change for a particular event. (all the of the Pen2D events have the same timecode - 22781412).

FYI, I'm running the LINUX GCC library on Ubuntu 16.04 on a Desktop. My Slate firmware version is 4.0.19.0.

Hope this info helps? I'm looking forward to the new API release!

--- output ---

Attempting to connect to ISKN Slate ...
Slate connected!
Subscribe successful
processEvent type: 1 timecode: 1
EVT_STATE Battery: 100 isBatteryInCharge: 1
processEvent type: 4 timecode: 22781412
EVT_PEN_2D Touch 0 Pos (138.44,160.6) Rot (154.77,-42.06)
processEvent type: 4 timecode: 22781412
EVT_PEN_2D Touch 0 Pos (137.96,160.21) Rot (154.31,-43)
processEvent type: 4 timecode: 22781412
EVT_PEN_2D Touch 0 Pos (137.87,160) Rot (154.96,-43.77)
processEvent type: 4 timecode: 22781412
EVT_PEN_2D Touch 0 Pos (137.42,159.51) Rot (155.55,-43.85)
processEvent type: 4 timecode: 22781412
EVT_PEN_2D Touch 0 Pos (137.21,159.38) Rot (156.22,-44.39)
processEvent type: 4 timecode: 22781412
EVT_PEN_2D Touch 0 Pos (137.08,159.14) Rot (156.14,-42.75)
processEvent type: 4 timecode: 22781412
EVT_PEN_2D Touch 0 Pos (136.9,158.95) Rot (156.29,-42.34)
processEvent type: 4 timecode: 22781412
EVT_PEN_2D Touch 0 Pos (136.52,158.88) Rot (156.37,-41.82)
processEvent type: 4 timecode: 22781412
EVT_PEN_2D Touch 0 Pos (136.45,158.73) Rot (157.15,-40.48)
processEvent type: 4 timecode: 22781412
EVT_PEN_2D Touch 0 Pos (136.46,158.53) Rot (157.55,-40.91)
processEvent type: 4 timecode: 22781412
EVT_PEN_2D Touch 0 Pos (136.5,158.33) Rot (158.39,-42.4)
processEvent type: 4 timecode: 22781412
EVT_PEN_2D Touch 0 Pos (136.21,158.06) Rot (158.58,-43.3)
processEvent type: 4 timecode: 22781412
EVT_PEN_2D Touch 0 Pos (136.06,157.93) Rot (158.54,-42.88)
processEvent type: 4 timecode: 22781412
EVT_PEN_2D Touch 0 Pos (135.86,157.78) Rot (158.86,-40.94)
processEvent type: 4 timecode: 22781412
EVT_PEN_2D Touch 0 Pos (135.76,157.47) Rot (158.03,-38.49)
processEvent type: 4 timecode: 22781412
EVT_PEN_2D Touch 0 Pos (135.78,157.35) Rot (158.26,-38.58)
processEvent type: 4 timecode: 22781412
EVT_PEN_2D Touch 0 Pos (135.93,157.28) Rot (158.53,-38.4)
processEvent type: 4 timecode: 22781412
EVT_PEN_2D Touch 0 Pos (135.31,156.85) Rot (160.26,-40.14)
processEvent type: 4 timecode: 22781412
EVT_PEN_2D Touch 0 Pos (135.45,156.84) Rot (160.97,-39.38)
processEvent type: 4 timecode: 22781412
EVT_PEN_2D Touch 0 Pos (135.58,156.77) Rot (161.33,-39.19)
processEvent type: 4 timecode: 22781412
EVT_PEN_2D Touch 0 Pos (135.73,156.78) Rot (161.5,-40.37)
processEvent type: 4 timecode: 22781412
EVT_PEN_2D Touch 0 Pos (136.09,156.71) Rot (161.77,-40.45)
processEvent type: 4 timecode: 22781412
EVT_PEN_2D Touch 0 Pos (136.46,156.73) Rot (162.3,-40.61)
processEvent type: 4 timecode: 22781412
EVT_PEN_2D Touch 0 Pos (136.65,156.68) Rot (162.54,-40.49)
processEvent type: 4 timecode: 22781412
EVT_PEN_2D Touch 0 Pos (136.99,156.52) Rot (162.72,-40.74)
processEvent type: 4 timecode: 22781412
EVT_PEN_2D Touch 0 Pos (137.5,156.52) Rot (163.61,-39.82)
processEvent type: 4 timecode: 22781412
EVT_PEN_2D Touch 0 Pos (137.77,156.45) Rot (163.99,-39.9)
processEvent type: 4 timecode: 22781412
EVT_PEN_2D Touch 0 Pos (138.1,156.32) Rot (164.59,-40.04)
processEvent type: 4 timecode: 22781412
EVT_PEN_2D Touch 0 Pos (138.32,156.22) Rot (164.9,-39.24)
processEvent type: 4 timecode: 22781412
EVT_PEN_2D Touch 1 Pos (138.55,156.18) Rot (165.37,-39.55)
processEvent type: 4 timecode: 22781412
EVT_PEN_2D Touch 1 Pos (138.69,156.01) Rot (161.86,-39.53)
processEvent type: 4 timecode: 22781412
EVT_PEN_2D Touch 0 Pos (138.44,156.05) Rot (145.38,-29.06)
processEvent type: 4 timecode: 22781412
EVT_PEN_2D Touch 0 Pos (137.68,156.27) Rot (143.14,-33.6)
processEvent type: 4 timecode: 22781412
EVT_PEN_2D Touch 0 Pos (136.66,156.77) Rot (141.15,-36.94)
processEvent type: 4 timecode: 22781412
EVT_PEN_2D Touch 0 Pos (133.81,158.17) Rot (139.55,-38.56)
processEvent type: 3 timecode: 1241211261
EVT_SOFTWARE SE_HANDSHAKE
processEvent type: 3 timecode: 1241211261
EVT_SOFTWARE SE_HANDSHAKE
processEvent type: 3 timecode: 1241211261
EVT_SOFTWARE SE_HANDSHAKE
processEvent type: 3 timecode: 1241211261
EVT_SOFTWARE SE_HANDSHAKE
processEvent type: 3 timecode: 1241211261
EVT_SOFTWARE SE_OBJECT_IN Pen in: 4
processEvent type: 4 timecode: 22781412
EVT_PEN_2D Touch 0 Pos (133.32,179.22) Rot (143.44,-52.03)
processEvent type: 4 timecode: 22781412
EVT_PEN_2D Touch 0 Pos (133.4,179.28) Rot (144.2,-52.41)
processEvent type: 4 timecode: 22781412
EVT_PEN_2D Touch 0 Pos (133.27,179.09) Rot (145.3,-52.75)
processEvent type: 4 timecode: 22781412
EVT_PEN_2D Touch 0 Pos (133.55,178.91) Rot (145.55,-52.33)
processEvent type: 4 timecode: 22781412
EVT_PEN_2D Touch 0 Pos (133.7,178.92) Rot (146.21,-52.6)
processEvent type: 4 timecode: 22781412
EVT_PEN_2D Touch 0 Pos (133.91,178.75) Rot (146.65,-53.78)
processEvent type: 4 timecode: 22781412
EVT_PEN_2D Touch 0 Pos (134.12,178.7) Rot (147.2,-55.03)
processEvent type: 4 timecode: 22781412
EVT_PEN_2D Touch 0 Pos (134.27,178.42) Rot (146.94,-55.5)
processEvent type: 4 timecode: 22781412
EVT_PEN_2D Touch 0 Pos (134.54,178.15) Rot (147.49,-56.13)
processEvent type: 4 timecode: 22781412
EVT_PEN_2D Touch 0 Pos (134.77,177.99) Rot (147.43,-57.01)
processEvent type: 4 timecode: 22781412
EVT_PEN_2D Touch 0 Pos (135.12,177.7) Rot (148.2,-57.33)
processEvent type: 4 timecode: 22781412
EVT_PEN_2D Touch 0 Pos (135.48,177.42) Rot (148.28,-56.42)
processEvent type: 4 timecode: 22781412
EVT_PEN_2D Touch 0 Pos (135.76,177.29) Rot (148.58,-56.81)
processEvent type: 4 timecode: 22781412
EVT_PEN_2D Touch 0 Pos (136.03,177.03) Rot (149.25,-57.22)
processEvent type: 4 timecode: 22781412
EVT_PEN_2D Touch 0 Pos (136.39,176.73) Rot (149.8,-58.45)
processEvent type: 4 timecode: 22781412
EVT_PEN_2D Touch 0 Pos (136.61,176.58) Rot (150.87,-59.25)
processEvent type: 4 timecode: 22781412
EVT_PEN_2D Touch 0 Pos (136.88,176.3) Rot (151.09,-60.66)
processEvent type: 4 timecode: 22781412
EVT_PEN_2D Touch 0 Pos (136.93,176) Rot (151.28,-60.97)
processEvent type: 4 timecode: 22781412
EVT_PEN_2D Touch 0 Pos (137.06,175.82) Rot (151.91,-61.6)
processEvent type: 4 timecode: 22781412
EVT_PEN_2D Touch 0 Pos (137.31,175.57) Rot (152.16,-59.87)
processEvent type: 4 timecode: 22781412
EVT_PEN_2D Touch 0 Pos (137.63,175.36) Rot (151.66,-60.47)
processEvent type: 4 timecode: 22781412
EVT_PEN_2D Touch 0 Pos (138.01,175.15) Rot (151.66,-60.75)
processEvent type: 4 timecode: 22781412
EVT_PEN_2D Touch 0 Pos (138.4,175.15) Rot (152.01,-61.69)
processEvent type: 4 timecode: 22781412
EVT_PEN_2D Touch 0 Pos (138.57,175.08) Rot (152.44,-62.25)
processEvent type: 4 timecode: 22781412
EVT_PEN_2D Touch 0 Pos (138.85,174.89) Rot (152.56,-63.21)
processEvent type: 4 timecode: 22781412
EVT_PEN_2D Touch 0 Pos (138.84,174.69) Rot (152.61,-64.26)
processEvent type: 4 timecode: 22781412
EVT_PEN_2D Touch 0 Pos (138.94,174.66) Rot (152.88,-64.49)
processEvent type: 4 timecode: 22781412
EVT_PEN_2D Touch 0 Pos (139.09,174.66) Rot (153.18,-64.33)
processEvent type: 4 timecode: 22781412
EVT_PEN_2D Touch 0 Pos (139.33,174.63) Rot (153.84,-63.75)
processEvent type: 4 timecode: 22781412
EVT_PEN_2D Touch 0 Pos (139.56,174.55) Rot (153.96,-63.72)
processEvent type: 4 timecode: 22781412
EVT_PEN_2D Touch 0 Pos (139.77,174.63) Rot (154.12,-63.13)
processEvent type: 4 timecode: 22781412
EVT_PEN_2D Touch 0 Pos (139.99,174.74) Rot (154.19,-64.02)
processEvent type: 4 timecode: 22781412
EVT_PEN_2D Touch 0 Pos (140.1,174.78) Rot (154.29,-63.97)
processEvent type: 4 timecode: 22781412
EVT_PEN_2D Touch 0 Pos (140.13,174.77) Rot (154.05,-64.38)
processEvent type: 4 timecode: 22781412
EVT_PEN_2D Touch 0 Pos (140.14,174.74) Rot (153.96,-63.68)
processEvent type: 4 timecode: 22781412
EVT_PEN_2D Touch 0 Pos (140.11,174.8) Rot (153.81,-63.12)
processEvent type: 4 timecode: 22781412
EVT_PEN_2D Touch 0 Pos (139.96,174.79) Rot (153.61,-62.33)
processEvent type: 4 timecode: 22781412
EVT_PEN_2D Touch 0 Pos (140.09,174.95) Rot (153.4,-62.05)
processEvent type: 4 timecode: 22781412
EVT_PEN_2D Touch 0 Pos (139.99,175.01) Rot (153.27,-61.66)
processEvent type: 4 timecode: 22781412
EVT_PEN_2D Touch 0 Pos (139.89,175.22) Rot (152.81,-60.51)
processEvent type: 4 timecode: 22781412
EVT_PEN_2D Touch 0 Pos (139.66,175.36) Rot (152.32,-59.38)
processEvent type: 4 timecode: 22781412
EVT_PEN_2D Touch 0 Pos (139.33,175.56) Rot (150.76,-58.15)
processEvent type: 4 timecode: 22781412
EVT_PEN_2D Touch 0 Pos (138.91,175.76) Rot (149.67,-57.3)
processEvent type: 4 timecode: 22781412
EVT_PEN_2D Touch 0 Pos (138.5,175.98) Rot (148.53,-55.63)
processEvent type: 4 timecode: 22781412
EVT_PEN_2D Touch 0 Pos (138.06,176.15) Rot (146.52,-56.97)
processEvent type: 4 timecode: 22781412
EVT_PEN_2D Touch 0 Pos (137.35,176.39) Rot (144.91,-56.64)
processEvent type: 4 timecode: 22781412
EVT_PEN_2D Touch 0 Pos (136.53,176.59) Rot (143.69,-55.77)
processEvent type: 4 timecode: 22781412
EVT_PEN_2D Touch 0 Pos (135.28,176.87) Rot (144.18,-55.58)
processEvent type: 4 timecode: 22781412
EVT_PEN_2D Touch 0 Pos (134.04,177.14) Rot (142.71,-52.96)
processEvent type: 4 timecode: 22781412
EVT_PEN_2D Touch 0 Pos (132.6,177.33) Rot (141.19,-52.9)
processEvent type: 4 timecode: 22781412
EVT_PEN_2D Touch 0 Pos (130.98,177.89) Rot (139.52,-52.95)
processEvent type: 4 timecode: 22781412
EVT_PEN_2D Touch 0 Pos (129.55,178.13) Rot (138.53,-53.76)
processEvent type: 4 timecode: 22781412
EVT_PEN_2D Touch 0 Pos (128.18,178.34) Rot (137.21,-56.64)
processEvent type: 4 timecode: 22781412
EVT_PEN_2D Touch 0 Pos (127.12,178.76) Rot (136.4,-58.25)
processEvent type: 4 timecode: 22781412
EVT_PEN_2D Touch 0 Pos (126.16,178.94) Rot (133.87,-59.83)
processEvent type: 4 timecode: 22781412
EVT_PEN_2D Touch 0 Pos (125.82,179.09) Rot (131.72,-60.11)
processEvent type: 4 timecode: 22781412
EVT_PEN_2D Touch 0 Pos (125.75,178.95) Rot (130.49,-59.53)
processEvent type: 3 timecode: 1241211261
EVT_SOFTWARE SE_OBJECT_OUT Pen out: 4
processEvent type: 3 timecode: 1241211261
EVT_SOFTWARE SE_HANDSHAKE
processEvent type: 3 timecode: 1241211261
EVT_SOFTWARE SE_HANDSHAKE

  
Markdown is allowed