Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. Problem with Readline - I broke it !

Problem with Readline - I broke it !

Scheduled Pinned Locked Moved Visual Basic
comhelpannouncement
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    rfrank5356
    wrote on last edited by
    #1

    Hi - I have a small development app that (used to) talk to a servo on a com port, and get a status reply. I have somehow really fixed it (I tried to simplify the code) - but the symptoms are maddening, and I do not see what I did other than move a readline from a subroutine to be inline with the code. Here is what I have Public ServoCommName As String = "COM4" Public ServoCommSpeed As Integer = 9600 Public ServoCommdataOut As String Public ServoCommDataIn As String Public ServoCommParity As System.IO.Ports.Parity Public ServoCommDataBits As Integer Public ServoCommStopBits As System.IO.Ports.StopBits Public Com2 As SerialPort = My.Computer.Ports.OpenSerialPort(ServoCommName, ServoCommSpeed, IO.Ports.Parity.None, 8, IO.Ports.StopBits.One) Then the subroutine . . . Public Sub GetServoStatus() ' Sends a status request and then gets Status from the Servo serial port. ServoCommdataOut = cstCameraServoAddress & "&R" Call SendSerialData() 'This will return the Firmware Version 'just in case wait 500 ms ' I have tried all sorts of delays . . . it worked before with 500 Call DelayTimer(DelayTime) ServoCommDataIn = Com2.ReadLine() MsgBox("End Read" & DelayTime & ServoCommDataIn) outLabel = "Read Servo" outMessage = ServoCommDataIn Call WriteToLog(outLabel, outMessage) ServoStatusBoxOut = "Ready" ServoStatusBox = ServoStatusBoxOut End Sub Here is the portmonitor recording for this part of the code . . . The response comes in on line 52 and portmon says it is fine ! 32 7:18:29 AM CameraControlV1 IOCTL_SERIAL_SET_BAUD_RATE slabser1 SUCCESS Rate: 9600 33 7:18:29 AM CameraControlV1 IOCTL_SERIAL_CLR_RTS slabser1 SUCCESS 34 7:18:29 AM CameraControlV1 IOCTL_SERIAL_CLR_DTR slabser1 SUCCESS 35 7:18:29 AM CameraControlV1 IOCTL_SERIAL_SET_LINE_CONTROL slabser1 SUCCESS StopBits: 1 Parity: NONE WordLength: 8 36 7:18:29 AM CameraControlV1 IOCTL_SERIAL_SET_CHAR slabser1 SUCCESS EOF:1a ERR:0 BRK:0 EVT:1a XON:11 XOFF:13 37 7:18:29 AM CameraControlV1 IOCTL_SERIAL_SET_HANDFLOW slabser1 SUCCESS Shake:0 Replace:0 XonLimit:128 XoffLimit:128 38 7:18:29 AM CameraControlV1 IOCTL_SERIAL_CLR_RTS slabser1 SUCCESS 39 7:18:29 AM CameraControlV1 IOCTL_SERIAL_SET_TIMEOUTS slabser1 SUCCESS RI:-1 RM:-1 RC:-2 WM:0 WC

    L 1 Reply Last reply
    0
    • R rfrank5356

      Hi - I have a small development app that (used to) talk to a servo on a com port, and get a status reply. I have somehow really fixed it (I tried to simplify the code) - but the symptoms are maddening, and I do not see what I did other than move a readline from a subroutine to be inline with the code. Here is what I have Public ServoCommName As String = "COM4" Public ServoCommSpeed As Integer = 9600 Public ServoCommdataOut As String Public ServoCommDataIn As String Public ServoCommParity As System.IO.Ports.Parity Public ServoCommDataBits As Integer Public ServoCommStopBits As System.IO.Ports.StopBits Public Com2 As SerialPort = My.Computer.Ports.OpenSerialPort(ServoCommName, ServoCommSpeed, IO.Ports.Parity.None, 8, IO.Ports.StopBits.One) Then the subroutine . . . Public Sub GetServoStatus() ' Sends a status request and then gets Status from the Servo serial port. ServoCommdataOut = cstCameraServoAddress & "&R" Call SendSerialData() 'This will return the Firmware Version 'just in case wait 500 ms ' I have tried all sorts of delays . . . it worked before with 500 Call DelayTimer(DelayTime) ServoCommDataIn = Com2.ReadLine() MsgBox("End Read" & DelayTime & ServoCommDataIn) outLabel = "Read Servo" outMessage = ServoCommDataIn Call WriteToLog(outLabel, outMessage) ServoStatusBoxOut = "Ready" ServoStatusBox = ServoStatusBoxOut End Sub Here is the portmonitor recording for this part of the code . . . The response comes in on line 52 and portmon says it is fine ! 32 7:18:29 AM CameraControlV1 IOCTL_SERIAL_SET_BAUD_RATE slabser1 SUCCESS Rate: 9600 33 7:18:29 AM CameraControlV1 IOCTL_SERIAL_CLR_RTS slabser1 SUCCESS 34 7:18:29 AM CameraControlV1 IOCTL_SERIAL_CLR_DTR slabser1 SUCCESS 35 7:18:29 AM CameraControlV1 IOCTL_SERIAL_SET_LINE_CONTROL slabser1 SUCCESS StopBits: 1 Parity: NONE WordLength: 8 36 7:18:29 AM CameraControlV1 IOCTL_SERIAL_SET_CHAR slabser1 SUCCESS EOF:1a ERR:0 BRK:0 EVT:1a XON:11 XOFF:13 37 7:18:29 AM CameraControlV1 IOCTL_SERIAL_SET_HANDFLOW slabser1 SUCCESS Shake:0 Replace:0 XonLimit:128 XoffLimit:128 38 7:18:29 AM CameraControlV1 IOCTL_SERIAL_CLR_RTS slabser1 SUCCESS 39 7:18:29 AM CameraControlV1 IOCTL_SERIAL_SET_TIMEOUTS slabser1 SUCCESS RI:-1 RM:-1 RC:-2 WM:0 WC

      L Offline
      L Offline
      Lucan07
      wrote on last edited by
      #2

      I'm no expert but you moved a line of code maybe with a cut and paste maybe you got an extra line return in there somewhere. Might be completely silly but the simple things first

      Bird with no beak was born to succeed.

      R 1 Reply Last reply
      0
      • L Lucan07

        I'm no expert but you moved a line of code maybe with a cut and paste maybe you got an extra line return in there somewhere. Might be completely silly but the simple things first

        Bird with no beak was born to succeed.

        R Offline
        R Offline
        rfrank5356
        wrote on last edited by
        #3

        Thanks for the response - I have looked pretty carefully but nothing is obvious - the problem seems to be that PortMon sees the string comming in - but the readline(ServoDataIn) statement in the vb code either gets an incomplete transfer or garbage - I am not certain which . . . this is all very slow stuff and not much data is moving . . .

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups