Or, you could get similar results by calling the ReadLine() method with the NewLine property set to 13(carriage return= \r) in a similar way.įor example, if the end of the data is 10(line feed= \n), you can call it like this article.When raising children, protecting them from various online dangers can be a difficult task since many tools provide you with incomplete solutions. However, since the initial value should be InfiniteTimeout, changing the value cannot be expected to have any effect.Īlternatively, if all the data you receive is a string, ending in 13(carriage return= \r) and it doesn't appear in the middle of the data, you can use the ReadTo() method. Perhaps by adjusting the value of the ReadTimeout property, it may be possible to finish Read() after receiving all the data. You need to get and save the data and size of the Read() result and add a process to check if all the data was received normally. There is no concept of packets like TCP/IP. The serial port communicates in 1-byte units at a minimum. It's not odd behavior, it can happen normally if you use the Read() method on the serial port. Hit Line breakpoint on 'C:\Users\james\Desktop\VStest2a.ps1:4' PS C:\Users\james\Desktop> C:\Users\james\Desktop\VStest2a.ps1 Write-Host "portreturn2" $portreturn -foreground black -BackgroundColor white Write-Host "portreturn1" $portreturn -foreground black -BackgroundColor white $port.Read($portreturn, 0, $portreturn.Length) $port = new-Object System.IO.Ports.SerialPort COM3, 9600, None, 8, one When I add a second read, I get the remaining 8īut when I add a break point and step through it using the debugger, I get all 9 on the first read.Īny ideas what could be causing this odd behavior?Īny suggestions on any better ways to do this? When I run the code, I only get a one-digit reply I send a request for the display status either on or off and should get a 9 digit replyĮither 56 48 49 114 108 48 48 49 13 reply for on I am trying to set up serial port communication with a ViewSonic Display using PowerShell.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |