CEF3 ,JS to open ,read and write the computer's serial port

Having problems with building or using CEF's C/C++ APIs? This forum is here to help. Please do not post bug reports or feature requests here.

CEF3 ,JS to open ,read and write the computer's serial port

Postby wowocpp » Sat Dec 02, 2017 9:21 pm

Hello ,I have a win32 project ,changed from cefsimple, CEF3
I want to use Java script function to open ,read and write the computer's serial port and usb port.
how can I to do this ?

Those functions are not blocked.only take a little time.
I want the functions to return values to JS

I hava read the page :https://bitbucket.org/chromiumembedded/cef/wiki/GeneralUsage
and https://bitbucket.org/chromiumembedded/ ... gration.md

I find two ways ,one way is PPAPI Plugin ,Is it the correct way to do this ?

another way is "Functions and Window Binding ",
In the render process ,implemente the function to open ,read and write the computer's serial port and usb port
by
Code: Select all
class MyV8Handler : public CefV8Handler {
public:
  MyV8Handler() {}

  virtual bool Execute(const CefString& name,
                       CefRefPtr<CefV8Value> object,
                       const CefV8ValueList& arguments,
                       CefRefPtr<CefV8Value>& retval,
                       CefString& exception) OVERRIDE {
    if (name == "myfunc") {
      // Return my string value.
      retval = CefV8Value::CreateString("My Value!");
      return true;
    }

    // Function does not exist.
    return false;
  }

  // Provide the reference counting implementation for this class.
  IMPLEMENT_REFCOUNTING(MyV8Handler);
};


Is this way correct ? please give me some suggestions or example code and demo code
wowocpp
Newbie
 
Posts: 1
Joined: Sat Dec 02, 2017 8:51 am

Re: CEF3 ,JS to open ,read and write the computer's serial

Postby magreenblatt » Sun Dec 03, 2017 4:17 pm

You will need to communicate with the serial port using native code in the browser process. You can then pass that information to/from JavaScript running in the renderer process as described at https://bitbucket.org/chromiumembedded/ ... t-bindings
magreenblatt
Site Admin
 
Posts: 12409
Joined: Fri May 29, 2009 6:57 pm


Return to Support Forum

Who is online

Users browsing this forum: Google [Bot] and 55 guests