0

I want to send data out of my C++ program into a tty port. However, I am experiencing significant problems regarding using system(echo > tty) and ofstream dev(tty).

I found that the only thing that works is screen tty.device from the command line, so is it possible for me to open up my device using screen from c++ and then send data to it from my c++ program?

Python is fine too if a solution exists.

StarckOverflar
  • 1,577
  • 2
  • 10
  • 13
  • Is there an obvious way to do this hence the downvotes? – StarckOverflar Nov 19 '18 at 01:31
  • Sorry, don't know much about MacOS. If you are interested, I could describe (with code snippets) how I do this on Ubuntu, you'd recognize the C++, and might get some clues on questions to ask ( for how do this on MacOS). – 2785528 Nov 19 '18 at 04:37
  • check this [link](https://stackoverflow.com/questions/44042413/does-bidirectional-popen-work-on-mac-os-x-in-c) it might help – yashC Nov 19 '18 at 11:33
  • @2785528 Yeah if you have any code snippets that would be great! – StarckOverflar Nov 19 '18 at 16:59
  • @yashC Thanks a lot! That might be what I'm looking for. However, I'm doing this: FILE *pout; pout = popen("screen tty.MobileRobot-RNI-SPP", "w"); fprintf(pout,"hello"); – StarckOverflar Nov 19 '18 at 17:12
  • @yashC Then it's giving me a "Must be connected to a terminal" message. Why's that? – StarckOverflar Nov 19 '18 at 17:13

0 Answers0