2023-10-13 09:43:42 +02:00
|
|
|
import { invoke } from "@tauri-apps/api/tauri"
|
2023-10-16 19:01:34 +02:00
|
|
|
import { message } from '@tauri-apps/api/dialog';
|
2023-10-13 09:43:42 +02:00
|
|
|
import { useLocalStorage } from '@vueuse/core'
|
|
|
|
|
|
|
|
const serialConfig = useLocalStorage('serialConfig', { port: '', baud: 9600 })
|
|
|
|
|
2023-10-16 19:01:34 +02:00
|
|
|
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' });
|
|
|
|
}
|
2023-10-13 09:43:42 +02:00
|
|
|
}
|