linux.d.ts 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. import { Poller } from './poller';
  2. import { BindingInterface, OpenOptions, PortStatus, SetOptions, UpdateOptions } from '@serialport/bindings-interface';
  3. import { BindingPortInterface } from '.';
  4. export interface LinuxOpenOptions extends OpenOptions {
  5. /** Defaults to none */
  6. parity?: 'none' | 'even' | 'odd';
  7. /** see [`man termios`](http://linux.die.net/man/3/termios) defaults to 1 */
  8. vmin?: number;
  9. /** see [`man termios`](http://linux.die.net/man/3/termios) defaults to 0 */
  10. vtime?: number;
  11. }
  12. export interface LinuxPortStatus extends PortStatus {
  13. lowLatency: boolean;
  14. }
  15. export interface LinuxSetOptions extends SetOptions {
  16. /** Low latency mode */
  17. lowLatency?: boolean;
  18. }
  19. export type LinuxBindingInterface = BindingInterface<LinuxPortBinding, LinuxOpenOptions>;
  20. export declare const LinuxBinding: LinuxBindingInterface;
  21. /**
  22. * The linux binding layer
  23. */
  24. export declare class LinuxPortBinding implements BindingPortInterface {
  25. readonly openOptions: Required<LinuxOpenOptions>;
  26. readonly poller: Poller;
  27. private writeOperation;
  28. fd: number | null;
  29. constructor(fd: number, openOptions: Required<LinuxOpenOptions>);
  30. get isOpen(): boolean;
  31. close(): Promise<void>;
  32. read(buffer: Buffer, offset: number, length: number): Promise<{
  33. buffer: Buffer;
  34. bytesRead: number;
  35. }>;
  36. write(buffer: Buffer): Promise<void>;
  37. update(options: UpdateOptions): Promise<void>;
  38. set(options: LinuxSetOptions): Promise<void>;
  39. get(): Promise<LinuxPortStatus>;
  40. getBaudRate(): Promise<{
  41. baudRate: number;
  42. }>;
  43. flush(): Promise<void>;
  44. drain(): Promise<void>;
  45. }