gerritv / Grbl-Panel

A control panel for Grbl
MIT License
180 stars 102 forks source link

Port Scanning Problem #39

Closed joebananas10 closed 8 years ago

joebananas10 commented 8 years ago

I've read a couple of the issues about the port scanning problem under Windows 10. The fix, for some, has been to run under Windows 7 compatibility mode but that doesn't seem to solve the problem for everyone.

In my case I just noticed that I always had extra characters after the comport name like in other examples of this issue, e.g. COM4漢. My solution doesn't address the problem directly but just finds a work around. I replaced the code of the rescan() function in GrblIIF from this,

Public Function rescan() As String()
    ' scan for com ports again
    Return IO.Ports.SerialPort.GetPortNames
End Function    

to this,

Public Function rescan() As String()
    ' scan for com ports again
    Dim aTemp() As String

    aTemp = IO.Ports.SerialPort.GetPortNames
    For iCounter As Integer = 0 To UBound(aTemp)
        aTemp(iCounter) = "COM" & Val(Right(aTemp(iCounter), Len(aTemp(iCounter)) - 3))
    Next
    Return aTemp
End Function

What it does is, instead of just reading the port names that are returned by the GetPortNames() function it takes the list and rebuilds it without the extraneous characters. I recreated the name of the comport by taking the portion after the word COM and converting it to a number. The VAL() function converts the numbers it finds to a number and throws the extra characters away. Then I concatenate the word COM back into the name. This fills the list and when I try to connect to my comport it calls the correct port's name.

I realize it doesn't address the problem of why the comport names are coming in wrong in the first place but it does work.

I hope that's helpful to anyone.

gerritv commented 8 years ago

Fixed in V1.0.7.0, moved to .Net 4.5.2