I don't see how your code would work, you are not specifying which port, the port parameters (speed, parity, etc) or flow control (rts/cts etc). They must match your target device.