New topic: Serial Port take 2
<http://forums.realsoftware.com/viewtopic.php?t=29410> Page 1 of 1 [ 1 post ] Previous topic | Next topic Author Message MagicMatt Post subject: Serial Port take 2Posted: Wed Aug 05, 2009 2:35 pm Joined: Tue Aug 05, 2008 1:20 pm Posts: 222 Ok, here's what I need to setup. This is a Windows XP SP3 system, with a serial device on COM1 that I need to talk to. The data I'm trying to send is two Chr code 10 characters, then the word TEST followed by another Chr 10 character. In response to this, I should get the word TEST back, followed by Chr13 and Chr10. I am using REALBasic2008r5.1 The problems I'm having are the same in the trial I downloaded also, so I don't believe the problem is to do with the version of REALBasic I'm using. I have established that nothing else is using the port. The settings that Windows reports when I talk to the system via HyperTerminal are... Baud: 19200 Parity: None Data bits: 8 Stop Bits: 1 Timeout: On XON/XOFF: Off CTS Handshaking: On DSR Handshaking: Off DSR Sensitivity: Off DTR Circuit: On RTS Circuit: Handshake Knowing that works, I conclude need the same in REALBasic. I have added a Serial control to a new project In the IDE I have selected the following: Name: Serial1 Super: Serial Scope: 0 - Public Index: Top: 348 Left: 20 TabPanelIndex: 0 Baud: 10 - 19200 Bits: 3 - 8 Data bits CTS: ticked DTR: not [quote][/quote]ticked Parity: 0 - no parity Stop: 0 - 1 stop bit XON: not ticked I see no option to choose which serial port the control refers to - strange, maybe I'm missing the obvious in the IDE?? The code within the Open() event of the only application window: Code: Serial1.SerialPort = System.SerialPort("COM1") If Serial1.Open then MsgBox "The serial port is open." Else MsgBox "The serial port could not be opened." End if This gives me the message "The serial port is open." Serial1.DataAvailable() is: Code: EF_Output.Text=EF_Output.Text+ "---------------"+chr(13)+Me.ReadAll() Serial1.Error() is: Code: MsgBox("Error from serial port:"+CStr(Serial1.LastErrorCode)) EF_Input and EF_Output are two EditFields. EFInput is a single line EditField, and EF_Output is a large multi-line EditField. I have also placed a button on the form, with this code in BevelButton1.Action() Code: Serial1.Write(CHR(10)+CHR(10)+EF_Command.Text+CHR(10)) What happens: When I ran the application, I was getting "Error from serial port: 102". I solved this by removing the Serial1.Baud command from the application completely. For some reason, ANY change to the baud rate within the application causes this error. It was always followed by "The port is open" however writing to the port showed no activity on the hardware. Having removed the setting of the baud rate and relying on the IDE I now have no error, but still no response from the hardware. I don't get an error either - just nothing happens at all when I put a command into EF_Input and click my button. Checking the status of the port after exiting my application shows this... Baud: 19200 Parity: None Data bits: 8 Stop Bits: 1 Timeout: On XON/XOFF: Off CTS Handshaking: On DSR Handshaking: Off DSR Sensitivity: Off DTR Circuit: Off RTS Circuit: Off Checking the box for DTR gives this result: Baud: 19200 Parity: None Data bits: 8 Stop Bits: 1 Timeout: On XON/XOFF: Off CTS Handshaking: On DSR Handshaking: Off DSR Sensitivity: Off DTR Circuit: Handshake RTS Circuit: Off I can't find an option to get the last two the way I need them, which is: DTR Circuit: On RTS Circuit: Handshake Can RB do that, and if so, how? _________________ REALBasic 2008r5.1 Professional Windows XP SP3 Toshiba Tecra A9-11M Laptop Intel Core2 Duo T7700 @ 2.4GHz with 2Gb RAM @ 800MHz plus various other WinTel machines. (and a broken MacBook Pro 3.1 with OS-X 10.5.2 with no networking or sound thanks to a lightening storm) Top Display posts from previous: All posts1 day7 days2 weeks1 month3 months6 months1 year Sort by AuthorPost timeSubject AscendingDescending Page 1 of 1 [ 1 post ] -- Over 1500 classes with 29000 functions in one REALbasic plug-in collection. The Monkeybread Software Realbasic Plugin v9.3. http://www.monkeybreadsoftware.de/realbasic/plugins.shtml [email protected]
