Serial port open error

When opening a serial port, the device I am trying to access may not have a baudrate of 9600 set so I will have to go thru each baudrate until the device opens correctly.

What error, ArgumentOutOfRangeException or an IOException or some other, should I look for after performing the Port.Open ? Or do I perform this check using the PortOpen statement ?

Sorry to have to ask all of these simple questions, but I am unsure how else to get the information ?

Is there any way that I can tell how to use the PortOpen procedures correctly, including the error handling too, so that I dont have to keep asking everyone ?

2 Answers 2

is what You should receive in case of errors.

You could find all exceptions explanation down there.

For more general advice, have a look at the System.IO.Ports namespace which has a more complete example. Personally I’d adapt what they have there to set your general port settings and then try a few different baud rates in debug mode (some bad, one known good). You’ll very quickly see what a bad configuration gives vs a good one. I’m assuming you have access to test the device here?

It’s worth noting that you won’t see any problems with the call to open the port (just opening it will only test that you’ve set some parameters which the port supports). You’ll start to see issues when you try and read/write to the device and it’s there that you’ll want to do the error checking for a valid baud rate.

Читайте также:  Broforce как играть вдвоем на одном компьютере

[EDIT] Try something along these lines (NOTE: I’ve not tested this with any hardware but it at least compiles):

О коптерах и не только

Есть проблемы при перепрошивке полетного контроллера? В большинстве случаев это проблемы с драйверами ПК, и сегодняшнее руководство может помочь вам.

Ошибки при перепрошивке ПК

При прошивке полетных контроллеров в Windows можно получить сообщение об ошибке:

Failed to open serial port

Последовательный порт исчезает и появляется снова при отключении и повторном подключении контроллера.

Или вы можете получить сообщение типа:

No response from bootloader, programming failed

Если вы можете подключиться к полетному контроллеру в Betaflight GUI, но просто не можете обновить прошивку, то это руководство поможет решить проблему

Если вы не можете подключиться к ПК в Betaflight GUI, тогда попробуйте вот этот фикс, перед обновлением прошивки.

Исправляем проблемы с драйверами при помощи ImpulseRC Driver Tool

Подключаем контроллер к компьютеру USB кабелем.

Скачиваем и запускаем ImpulseRC Driver Fixer Tool (это стороннее приложение, так что проверьте его антивирусником).

Программа автоматически найдет ПК и установит необходимый драйвер.

После окончания процедуры запускаем Betaflight GUI и видим «DFU» рядом с кнопкой «Connect» (вместо COM порта).

Теперь вы сможете нормально прошить ПК.

После перепрошивки в выпадающем списке появится обычный последовательный порт. Всё, можно работать и прошивать ПК как обычно, без проблем.

У меня не получается прошить ПК, я уже всё попробовал, вместо COM порта я вижу DFU, но прошить не получается, появляется сообщение об ошибке:

Read protection not active. USB device successfully closed

Перед прошивкой попробуйте убрать галочку «Full chip erase», после прошивки сможете удалить все настройки в консоли (CLI), для этого наберите «default» (без кавычек).

Читайте также:  Canyon cns gpw6 драйвер

Решение проблем с драйверами полетных контроллеров : 2 комментария

Здравствуйте! А что на счёт подключения ПК к Mac OS X или к Linux? Ну вот не пользуюсь я компьютерами с ОС Windows, что мне делать в этом случае? И как на счёт програматоров для регулей? Перефразирую вопрос — можно ли подключать регули и ПК к компьютерам Apple или к компьютерам с ОС Linux? Нужны ли FTDI адаптеры для перепрошивки регулей или можно на прямую к USB порту подключать?

Регули подключаются к компу через адаптер, это либо USB-UART адаптер, либо полетный контроллер в роли адаптера — fc passthrough).

Comments

Copy link Quote reply

per1234 commented Jun 1, 2015

Under Windows 7 64 bit using Arduino IDE hourly build 2015/06/01 09:34:
Once I get the Error opening serial port ‘COM12’. (Port not found) error the serial monitor won’t open any port until the IDE is restarted. This happens with any com port number. I don’t have this problem under 1.6.4. It is a bit difficult to get the error message. I can get it sometimes by:

  • Plug in the board to USB
  • Select a different port from the one the board is on
  • Select the port the board is on
  • Unplug the board from USB
  • Try to open the serial monitor. Console shows Error opening serial port ‘COM12’. (Port not found) . If that error doesn’t show then restart the IDE and repeat the process.
  • Plug the board back in to USB
  • Verify the port shows in the ports menu
  • Open serial monitor. Nothing happens. The same will happen for boards on a different port.
Читайте также:  Gtx 670 vs gtx 760

It may take a few tries to get the error message. I do not have this problem after the more common Board at COM12 is not available error.

Rate this post

Добавить комментарий

Ваш адрес email не будет опубликован. Обязательные поля помечены *