toos-halloween/toos-dashboard/src/composables/useSerial.js
2023-10-16 19:01:34 +02:00

15 lines
526 B
JavaScript

import { invoke } from "@tauri-apps/api/tauri"
import { message } from '@tauri-apps/api/dialog';
import { useLocalStorage } from '@vueuse/core'
const serialConfig = useLocalStorage('serialConfig', { port: '', baud: 9600 })
export async function useSerial(input) {
try {
await invoke('write_serial', { input: input + ";", portName: serialConfig.value.port, baud: serialConfig.value.baud });
} catch (err) {
console.error(err);
await message(err, { title: 'Error while writing serial', type: 'error' });
}
}