Shop OBEX P1 Docs P2 Docs Learn Events
getting an 'echo' on serial interface? — Parallax Forums

getting an 'echo' on serial interface?

hobbesiphobbesip Posts: 2
edited 2008-11-12 19:27 in BASIC Stamp
Hi. I have a BS2 breadboard, and i want to use the built-on db9 serial port to communicate with a linux terminal. I'm using DEBUG to send data, and SERIN to receive. Basicallly, i'm trying to get the stamp to work it's way though the username and password prompts, and then get the IP address of the host. What I finding, though (using ttysnoop on the terminal), is the data the terminal sends to the stamp, the stamp "echos" back to the terminal. The terminal interprets this as keystrokes as if entering the username. Is there any way to turn this off?

Here's a code snipet of what I'm attempting to do:

SERIN 16, MyBaud, 5000,noun, [noparse][[/noparse]WAIT("in:"), sData] 'wait for "login:" to show. If not within 5 sec, goto noun.
' BAFG.CDE
OUTH = %00000001 'Update display w/ progress

DEBUG "myusername",CR,LF
SERIN 16, MyBaud, [noparse][[/noparse]WAIT("rd:"), sData] 'wait for "Password:" to show.
OUTH = %00100001 'Update display w/ progress
PAUSE 10
DEBUG "mypassword", CR,LF
SERIN 16, MyBaud, [noparse][[/noparse]WAIT("]"), sData] 'wait for "]", which is the prompt.
OUTH = %01100001 'Update display w/ progress
'send command string to get IP address from host.
SEROUT 16, MyBaud, [noparse][[/noparse]"ifconfig | grep 'inet addr' | awk '{print $2}' | sed 's/addr://' | grep 172.25",CR,LF]
OUTH = %11100101 'Update display w/ progress
SERIN 16, MyBaud, [noparse][[/noparse]STR ByteArray \15 \CR] ' Read in the IP address to a char array
'
Thanks.

Comments

  • FranklinFranklin Posts: 4,747
    edited 2008-11-11 23:36
    Port '16' is the dedicated serial port and has a 'feature' that it echos data back. There is no way in software to disable this but you can use any other pin for serial data but you will need something like a max232 to connect this to the computer.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    - Stephen
  • RobotWorkshopRobotWorkshop Posts: 2,307
    edited 2008-11-11 23:39
    If you look at the schematic for the OEM Stamp of the BASIC Stamp modules you will see there is a 4.7K ohm resistor across the RX and TX lines. That is why you are seeing the echo.

    Robert
  • hobbesiphobbesip Posts: 2
    edited 2008-11-12 13:22
    Ah, bummer. I guess I'll go with Franklin's suggestion and use an I/O pin to a serial controller.

    Just out of curiosity, why is the 4.7K ohm resistor between the TX and RX pins?

    Thanks!
  • stamptrolstamptrol Posts: 1,731
    edited 2008-11-12 14:14
    Its part of a circuit that lets the Stamp "steal" negative voltage from another serial device (usually a PC). This is required because the stamp doesn't generate its own negative voltage.

    The popular Max232 and Max233 chips and their cousins are used for just such a reason.

    Cheers,

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Tom Sisk

    http://www.siskconsult.com
    ·
  • RobotWorkshopRobotWorkshop Posts: 2,307
    edited 2008-11-12 15:20
    I'd probably just keep the existing DB-9 for programming the chip and use another pair of pins as your TX/RX for your serial communication.

    If the echo isn't desirable then you can easily use a couple of the other pins and use a MAX232 as Tom suggested to translate the logic level signals to ones more suitable for a standard RS-232 serial connection.

    Alternatively if you just wanted the Stamp to talk to a PC that is running an application or terminal then you could look at the Parallax USB2SER or even better the PropPlug. These are basically just USB to logic level serial translators and it looks like a COM port on the PC. On the Stamp end just use the ground, TX, and RX signals. You can ignore the one normally used to reset the chips for programming.

    Robert
  • allanlane5allanlane5 Posts: 3,815
    edited 2008-11-12 19:09
    One suggestion that hasn't been made yet -- your program 'knows' what data it's sent to the BS2, it could simply remove that "echoed" data when it comes back.
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2008-11-12 19:27
    I agree with Allan. You can also write your Stamp program to prepend its response with a unique character. After your PC program sends its command, it would then just read and discard data from the Stamp until it reached that unique character, then begin reading the Stamp's response.

    -Phil
Sign In or Register to comment.