PDA

View Full Version : Downloading to BS2sx



tonio.k
03-02-2005, 09:13 PM
Hello everybody,

I've got a question about the software basic stamp editor, and the way used to download program from host PC to the BS2SX (with serial port). Indeed, download a program··with basic stamp editor modifies setting of the serial port.

when you start a PC, the settings are·:

Status for device COM1:
-----------------------
··· Baud:··········· 9600
··· Parity:········· None
··· Data Bits:······ 8
··· Stop Bits:······ 1
··· Timeout:········ OFF
··· XON/XOFF:······· OFF
··· CTS handshaking: OFF
··· DSR handshaking: OFF
··· DSR sensitivity: OFF
··· DTR circuit:···· ON
··· RTS circuit:···· ON

And after the download of program,·settings for serial port are :

··Status for device COM1:
-----------------------
··· Baud:··········· 9600
··· Parity:········· None
··· Data Bits:······ 8
··· Stop Bits:······ 1
··· Timeout:········ ON
··· XON/XOFF:······· OFF
··· CTS handshaking: OFF
··· DSR handshaking: OFF
··· DSR sensitivity: OFF
··· DTR circuit:···· OFF
··· RTS circuit:···· OFF

So DTR circuit and RTS circuit become OFF!
I would like to know how Basic Stamp Editor could modify these settings with windows XP. I know how to modify other settings like Baudrate,parity...but nothing about DTR circuit and RTS circuit. I need to do that with VC++.

I know you're not a Microsoft Win XP support, but· I use a programmatic reset of the BS2SX by modifying the state of the DTR line of the serial port. I can't use this programmatic reset if DTR circuit and RTS circuit are ON, so each time I restart my PC, I must download the prog from Basic Stamp Editor to BS2SX to modify serial port settings (DTR circuit and RTS circuit are OFF after) and only after that I can use properly Programmatic Reset of the BS2SX...And I can't write/erase indfinitely the memory of the BS2SX...

Thank you for your answer

Bye

Antoine

Post Edited By Moderator (Jon Williams) : 3/2/2005 2:24:37 PM GMT

allanlane5
03-02-2005, 10:59 PM
The problem you run into is that if DTR or RTS 'handshaking' is turned on, Windows XP will control them 'for' you. However, assuming you don't have handshaking turned on, you can directly control these two pins by:

1. Create a Handle to the port with
LocHandle = CreateFile(PortName, GEN_READ + GEN_WRITE, _
0, 0, EXISTING, OVERLAPPED, 0)

where "PortName" is like "COM1", "COM2", etc.

2. Control the pins with:
RetVal = EscapeCommFunction(PortHandle, Cmd)

where "PortHandle" is the "LocHandle" created above, and Cmd is one of:
' Function command values...
' SETXOFF==1, SETXON==2, SETRTS==3, CLRRTS==4, SETDTR==5, CLRDTR==6
' RESETDEV==7, SETBREAK==8, CLRBREAK==9

So, to set RTS OFF, use (PortHandle, 4). To set RTS ON, use (PortHandle, 3).