- 28 Mar 2025
- 2 읽을 분
- 기여자
- 인쇄
SDK Develop
- 업데이트 날짜 28 Mar 2025
- 2 읽을 분
- 기여자
- 인쇄
Learn how to start developing and iterating on your Tulip Edge Driver
Introduction
- What you will learn
- How to develop your first edge driver project
- Build a project
- Update the manifest and index files
- How to develop your first edge driver project
- What you will need (pre-requisites)
- Followed all of the steps in SDK Create
Getting Started
Once you have created your new Edge Driver with the create-edge-driver
tool, you're ready to start implementing your own driver code!
Updating manifest.json
First, we need to define the events and functions implemented by our driver. Device events can be used as triggers for logic in Tulip Apps. For example, you can set up an App trigger like:
"When my sensor fires a measurement event, store the temperature data in the 'Shop Floor Temperature' variable."
Drivers can also implement device functions, which can be executed in response to triggers within an app. For instance:
"When I click this button, call the 'Toggle Light' function on my device."
In this example, our driver will have no functions, but will fire an event called "data" when our sensor takes a measurement. Update the functions section in your src/manifest.json file by either leaving it empty or removing it entirely:
Then update the events section to define the shape of the "data" event. This event will be an object with two float properties, "temperature" and "humidity":
Updating index.ts
Now we will write the driver code that uses the Edge Driver SDK to find and connect to a serial port, reads incoming serial data, parses the JSON messages, and fires the "data" event using fireEvent(). Replace the example code in your src/index.ts file with this new code:
This is a very simple example that automatically tries to find the device using the Product ID of the USB device, a single time when the driver starts. The Edge Driver SDK also supports registering drivers to be started when new devices are detected by the system, which can help make more robust production drivers.
Building the Driver
After updating the driver code and manifest.json, build the driver again:
This will generate the compiled and bundled JavaScript file as well as a copy of the validated manifest inside the dist directory.