1
ndev = New SerialPort
ndev.PortName = ComboBoxEx1.SelectedItem.ToString
ndev.BaudRate = 115200
ndev.Parity = Parity.None
ndev.DataBits = 8
ndev.StopBits = 1
ndev.Open()
ndev.DiscardInBuffer()
ndev.DiscardOutBuffer()


ndev.WriteLine(TextBox1.Text)
Wait(50000)
ndev.Close()

I'm trying to write more than 255 characters, but it's causing serial communicatiob to hang. But when I cut the string to 255 characters before I write to serial port, it is going through. What seems to be my mistake? I tried coolterminal and send the whole data and it works. My baud rate is correct. I can't figure out what's causing the issue.

//WHOLE DATA NEED TO BE SEND
syscfg add PxCl 0x05007A7F 0x001E0032 0x41E7E560 0x41926C57 0x42C80000 0x41D0D254 0x415B6A16 0x43160000 0x41D0D254 0x415B6A16 0x43160000 0x435C0D91 0x3FDF9485 0x44998AE1 0x449963D7 0x4499923D 0x449A270A 0x41F6381D 0x41F90D84 0x420746A8 0x420C1E35 0x42200000 0x430BE189 0x4215F74C 0x42480000 0x43C29B9D 0x43C1D4FE 0x46132649 0x4379272B 0x1E358A47 0x1A081F02 0x45A56BC6 0x439B949C 0x458F375C 0x00000002 0x70000000


// I CAN ONLY SEND THIS, ANY CHARACTER ADDED WILL CAUSE SERIAL TO HANG 
syscfg add PxCl 0x05007A7F 0x001E0032 0x41E7E560 0x41926C57 0x42C80000 0x41D0D254 0x415B6A16 0x43160000 0x41D0D254 0x415B6A16 0x43160000 0x435C0D91 0x3FDF9485 0x44998AE1 0x449963D7 0x4499923D 0x449A270A 0x41F6381D 0x41F90D84 0x420746A8 0x420C1E35
jps
  • 20,041
  • 15
  • 75
  • 79
  • Hard to say without having your hardware, but check if DTR/RTS make a difference (~ https://stackoverflow.com/a/40848005/1462295 ), and I would register a data received event handler just to make sure nothing incoming is causing problems (i.e., keep incoming buffer empty ~ https://stackoverflow.com/a/10876408/1462295 ) – BurnsBA Oct 10 '22 at 14:57
  • Im using coolterm its like a tester of i send the full data and it was written in less than 5seconds, but when i trying my code i cant write more than 255 characters long – Randolf Mensurado Oct 10 '22 at 16:51
  • I recommend reading all of the documentation for [SerialPort](https://learn.microsoft.com/en-us/dotnet/api/system.io.ports.serialport?view=netframework-4.8). One setting that may be of interest is: [WriteBufferSize](https://learn.microsoft.com/en-us/dotnet/api/system.io.ports.serialport.writebuffersize?view=netframework-4.8). Refer to the documentation for your device, then ensure that you've set the correct SerialPort property values. – Tu deschizi eu inchid Oct 10 '22 at 17:30
  • The following may be helpful: https://stackoverflow.com/questions/70441938/get-scale-weight-over-serial-from-mettler-toledo-rice-lake-scale/70614758#70614758 – Tu deschizi eu inchid Oct 10 '22 at 17:38

1 Answers1

0

Fixed by chunking the string to 250 characters per write