资源简介

 serialport实现网页串口通讯

Access serial ports with JavaScript. Linux, OSX and Windows.


资源截图

代码片段和文件信息

#include “./darwin_list.h“

#include 
#include 
#include 
#include 

#if defined(MAC_OS_X_VERSION_10_4) && (MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_4)
#include 
#include 
#endif

#include 
#include 

uv_mutex_t list_mutex;
Boolean lockInitialised = FALSE;

NAN_METHOD(List) {
  // callback
  if (!info[0]->IsFunction()) {
    Nan::ThrowTypeError(“First argument must be a function“);
    return;
  }

  ListBaton* baton = new ListBaton();
  snprintf(baton->errorString sizeof(baton->errorString) ““);
  baton->callback.Reset(info[0].As());

  uv_work_t* req = new uv_work_t();
  req->data = baton;
  uv_queue_work(uv_default_loop() req EIO_List (uv_after_work_cb)EIO_AfterList);
}

void setIfNotEmpty(v8::Localject> item std::string key const char *value) {
  v8::Local v8key = Nan::New(key).ToLocalChecked();
  if (strlen(value) > 0) {
    Nan::Set(item v8key Nan::New(value).ToLocalChecked());
  } else {
    Nan::Set(item v8key Nan::Undefined());
  }
}


// Function prototypes
static kern_return_t FindModems(io_iterator_t *matchingServices);
static io_service_t GetUsbDevice(io_service_t service);
static stDeviceListItem* GetSerialDevices();


static kern_return_t FindModems(io_iterator_t *matchingServices) {
    kern_return_t     kernResult;
    CFMutableDictionaryRef  classesToMatch;
    classesToMatch = IOServiceMatching(kIOSerialBSDServiceValue);
    if (classesToMatch != NULL) {
        CFDictionarySetValue(classesToMatch
                             CFSTR(kIOSerialBSDTypeKey)
                             CFSTR(kIOSerialBSDAllTypes));
    }

    kernResult = IOServiceGetMatchingServices(kIOMasterPortDefault classesToMatch matchingServices);

    return kernResult;
}

static io_service_t GetUsbDevice(io_service_t service) {
  IOReturn status;
  io_iterator_t   iterator = 0;
  io_service_t    device = 0;

  if (!service) {
    return device;
  }

  status = IORegistryEntryCreateIterator(service
                                         kIOServicePlane
                                         (kIORegistryIterateParents | kIORegistryIterateRecursively)
                                         &iterator);

  if (status == kIOReturnSuccess) {
    io_service_t currentService;
    while ((currentService = IOIteratorNext(iterator)) && device == 0) {
      io_name_t serviceName;
      status = IORegistryEntryGetNameInPlane(currentService kIOServicePlane serviceName);
      if (status == kIOReturnSuccess && IOobjectConformsTo(currentService kIOUSBDeviceClassName)) {
        device = currentService;
      } else {
        // Release the service object which is no longer needed
        (void) IOobjectRelease(currentService);
      }
    }

    // Releas

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2020-12-24 21:42  node-serialport-master\
     文件          29  2020-12-24 21:42  node-serialport-master\.eslintignore
     文件        1491  2020-12-24 21:42  node-serialport-master\.eslintrc
     目录           0  2020-12-24 21:42  node-serialport-master\.generators\
     文件          33  2020-12-24 21:42  node-serialport-master\.generators\.npmignore
     文件        1104  2020-12-24 21:42  node-serialport-master\.generators\LICENSE
     文件         270  2020-12-24 21:42  node-serialport-master\.generators\README.md
     目录           0  2020-12-24 21:42  node-serialport-master\.generators\lib\
     文件         682  2020-12-24 21:42  node-serialport-master\.generators\lib\{{dashCase name}}.js
     文件         265  2020-12-24 21:42  node-serialport-master\.generators\lib\{{dashCase name}}.test.js
     文件         367  2020-12-24 21:42  node-serialport-master\.generators\package.json
     目录           0  2020-12-24 21:42  node-serialport-master\.github\
     文件          75  2020-12-24 21:42  node-serialport-master\.github\FUNDING.yml
     文件         123  2020-12-24 21:42  node-serialport-master\.github\ISSUE_TEMPLATE.md
     目录           0  2020-12-24 21:42  node-serialport-master\.github\ISSUE_TEMPLATE\
     文件         377  2020-12-24 21:42  node-serialport-master\.github\ISSUE_TEMPLATE\docs.md
     文件         853  2020-12-24 21:42  node-serialport-master\.github\ISSUE_TEMPLATE\proposal.md
     文件         547  2020-12-24 21:42  node-serialport-master\.github\ISSUE_TEMPLATE\support.md
     文件         503  2020-12-24 21:42  node-serialport-master\.github\lock.yml
     文件         886  2020-12-24 21:42  node-serialport-master\.github\stale.yml
     目录           0  2020-12-24 21:42  node-serialport-master\.github\workflows\
     文件        1035  2020-12-24 21:42  node-serialport-master\.github\workflows\build.yml
     文件         435  2020-12-24 21:42  node-serialport-master\.github\workflows\lint.yml
     文件        1270  2020-12-24 21:42  node-serialport-master\.github\workflows\test-merge.yml
     文件        1098  2020-12-24 21:42  node-serialport-master\.github\workflows\test.yml
     文件         108  2020-12-24 21:42  node-serialport-master\.gitignore
     文件         123  2020-12-24 21:42  node-serialport-master\.mocharc.js
     文件       49652  2020-12-24 21:42  node-serialport-master\CHANGELOG.md
     文件         429  2020-12-24 21:42  node-serialport-master\CODE_OF_CONDUCT.md
     文件        3517  2020-12-24 21:42  node-serialport-master\CONTRIBUTING.md
     文件        1105  2020-12-24 21:42  node-serialport-master\LICENSE
............此处省略238个文件信息

评论

共有 条评论