termios.c 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. // Copyright 2018 Espressif Systems (Shanghai) PTE LTD
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. //
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. #include "sdkconfig.h"
  15. #ifdef CONFIG_VFS_SUPPORT_TERMIOS
  16. #include <sys/termios.h>
  17. #include <sys/errno.h>
  18. speed_t cfgetispeed(const struct termios *p)
  19. {
  20. return p ? p->c_ispeed : B0;
  21. }
  22. speed_t cfgetospeed(const struct termios *p)
  23. {
  24. return p ? p->c_ospeed : B0;
  25. }
  26. int cfsetispeed(struct termios *p, speed_t sp)
  27. {
  28. if (p) {
  29. p->c_ispeed = sp;
  30. return 0;
  31. } else {
  32. errno = EINVAL;
  33. return -1;
  34. }
  35. }
  36. int cfsetospeed(struct termios *p, speed_t sp)
  37. {
  38. if (p) {
  39. p->c_ospeed = sp;
  40. return 0;
  41. } else {
  42. errno = EINVAL;
  43. return -1;
  44. }
  45. }
  46. #endif // CONFIG_VFS_SUPPORT_TERMIOS