Click here to Skip to main content
14,265,695 members

C / C++ / MFC

 
GeneralRe: Using fstream with USB Serial Port Pin
OscardelaGrouch7-Jul-18 15:46
memberOscardelaGrouch7-Jul-18 15:46 
GeneralRe: Using fstream with USB Serial Port Pin
speedbump997-Jul-18 16:10
memberspeedbump997-Jul-18 16:10 
GeneralRe: Using fstream with USB Serial Port Pin
OscardelaGrouch8-Jul-18 8:08
memberOscardelaGrouch8-Jul-18 8:08 
GeneralRe: Using fstream with USB Serial Port Pin
speedbump998-Jul-18 11:55
memberspeedbump998-Jul-18 11:55 
GeneralRe: Using fstream with USB Serial Port Pin
OscardelaGrouch9-Jul-18 8:49
memberOscardelaGrouch9-Jul-18 8:49 
AnswerRe: Using fstream with USB Serial Port Pin
OscardelaGrouch8-Jul-18 10:57
memberOscardelaGrouch8-Jul-18 10:57 
GeneralRe: Using fstream with USB Serial Port Pin
OscardelaGrouch9-Jul-18 8:52
memberOscardelaGrouch9-Jul-18 8:52 
AnswerRe: Using fstream with USB Serial Port Pin
Jochen Arndt10-Jul-18 3:31
mveJochen Arndt10-Jul-18 3:31 
That is probably because the serial device has echoing enabled. Such is used with serial terminals. When a character is received, it is send back to be displayed in the terminal (which usually does not display the character locally before sending it but waits for the echoed character to display that).

To avoid that you have to disable echoing by configuring the serial device initially:
stty -F /dev/ttyACM0 raw pass8 -echo -hup -clocal 9600
Note that it might be necessary to specify also other settings, remove some used above, and change the baud rate. See stty(1): change/print terminal line settings - Linux man page[^] for the available options. Before changing the options I suggest to execute
stty -F /dev/ttyACM0
to check the current settings.

As already mentioned by others it is rather uncommon to use C++ streams with serial ports. The common method is using termios and the IO functions from the standard C library, or a library like Serial Ports - 1.65.0[^] from Boost.Asio - 1.66.0[^] .

Related reads:
Serial HOWTO[^]
Serial Programming/Serial Linux - Wikibooks, open books for an open world[^]
GeneralRe: Using fstream with USB Serial Port Pin
OscardelaGrouch10-Jul-18 9:53
memberOscardelaGrouch10-Jul-18 9:53 
GeneralRe: Using fstream with USB Serial Port Pin
OscardelaGrouch10-Jul-18 18:43
memberOscardelaGrouch10-Jul-18 18:43 
GeneralRe: Using fstream with USB Serial Port Pin
Jochen Arndt10-Jul-18 21:09
mveJochen Arndt10-Jul-18 21:09 
GeneralRe: Using fstream with USB Serial Port Pin
OscardelaGrouch11-Jul-18 17:40
memberOscardelaGrouch11-Jul-18 17:40 
GeneralRe: Using fstream with USB Serial Port Pin
Jochen Arndt11-Jul-18 21:16
mveJochen Arndt11-Jul-18 21:16 
GeneralRe: Using fstream with USB Serial Port Pin
OscardelaGrouch12-Jul-18 18:42
memberOscardelaGrouch12-Jul-18 18:42 
GeneralRe: Using fstream with USB Serial Port Pin
Jochen Arndt12-Jul-18 20:59
mveJochen Arndt12-Jul-18 20:59 
GeneralRe: Using fstream with USB Serial Port Pin
OscardelaGrouch14-Jul-18 7:51
memberOscardelaGrouch14-Jul-18 7:51 
GeneralRe: Using fstream with USB Serial Port Pin
Jochen Arndt14-Jul-18 8:36
mveJochen Arndt14-Jul-18 8:36 
GeneralRe: Using fstream with USB Serial Port Pin
OscardelaGrouch14-Jul-18 8:38
memberOscardelaGrouch14-Jul-18 8:38 
GeneralRe: Using fstream with USB Serial Port Pin
Jochen Arndt14-Jul-18 8:43
mveJochen Arndt14-Jul-18 8:43 
GeneralRe: Using fstream with USB Serial Port Pin
OscardelaGrouch14-Jul-18 9:40
memberOscardelaGrouch14-Jul-18 9:40 
GeneralRe: Using fstream with USB Serial Port Pin
Jochen Arndt14-Jul-18 12:49
mveJochen Arndt14-Jul-18 12:49 
QuestionWhich do I use ide for learn c ++ Pin
Onur Çil6-Jul-18 2:33
memberOnur Çil6-Jul-18 2:33 
AnswerRe: Which do I use ide for learn c ++ Pin
Richard MacCutchan6-Jul-18 2:54
protectorRichard MacCutchan6-Jul-18 2:54 
AnswerRe: Which do I use ide for learn c ++ Pin
CPallini7-Jul-18 11:06
mveCPallini7-Jul-18 11:06 
GeneralRe: Which do I use ide for learn c ++ Pin
Daniel Pfeffer8-Jul-18 1:49
professionalDaniel Pfeffer8-Jul-18 1:49 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.