LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Выбор COM порта Selecting a COM port

Здравствуйте, существует проблема в выборе COM порта. При запуске ошибка в OpenComConfig...Неправильные настройки порта. Он определяется как COM1, а я его устанавливаю в COM10. Не поможете ли в данной проблеме? Заранее спасибо.

 

Hello, there is a problem in choosing a COM port. When starting, an error occurred in the Open Com Config...Incorrect port settings. It is defined as COM1, and I set it to COM10. Can you help me with this problem? Thank you in advance.

Download All
0 Kudos
Message 1 of 7
(1,501 Views)

@Andrey_26_Sarvn  ha scritto:

... It is defined as COM1, and I set it to COM10.


Can you explain what do you mean with this sentence? 



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
0 Kudos
Message 2 of 7
(1,466 Views)

Извиняюсь...этим я имел ввиду следующее. При нажатии кнопки Ports у меня должен быть настроен COM порт с теми установками которые я поставил, а происходит следующее... (высылаю скрины...)

 

Apologize...by this I meant the following. When I click the Ports button, I must have a COM port configured with the settings that I set, and the following happens ... (I send screenshots ...)

Download All
0 Kudos
Message 3 of 7
(1,450 Views)

That is you want to remap system device com1 to com10? You cannot do it in OpenComConfig!

There may be a way to do this in a CVI program by calling some appropriate API, but not the way you are doing it.

DeviceName in OpenComConfig is used to identify the port, but I suggest you to use the selector to set the port number, leave DeviceName blank and let the system handle it by itself: as you have found, a mismatch between port number and device name leads to errors in the command..



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
0 Kudos
Message 4 of 7
(1,446 Views)

I nevertheless suggest you to rethink the way you address this task: instead of  letting the user select a port between 1 and 10 (with the possibility to select a non existing port) you could use this library provided by msaxon several years ago and fill in a ring with all and only existing ports in the system.

 

Code to create a ring with ports in the system:

nports = LocateCom ("", portList, 16);
ClearListCtrl  (panelHandle, PANEL_PORTLIST);
InsertListItem (panelHandle, PANEL_PORTLIST, -1, "-/-", 0);
for (i = 0; i < nports; i++) {
	sprintf (msg, "COM%d", portList[i]);
	InsertListItem (panelHandle, PANEL_PORTLIST, -1, msg, portList[i]);
}

 

Previous suggestion to leave DeviceName blank remains valid.



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
0 Kudos
Message 5 of 7
(1,439 Views)

Извиняюсь...а что вы имеете ввиду оставить поле Device name пустым? И изначально забыл сказать, я руководствовался готовым примером из LabWindows, Serial.cws и хотел сделать похожее, потому что в мой проект именно часть конфигурации COM портов идеально подходит, только у них это работает, а у меня почему то нет. Заранее спасибо.

 

 I'm sorry... but what do you mean by leaving the Device name field empty? And initially I forgot to say, I was guided by a ready-made example from LabWindows, Serial.cws and wanted to do something similar, because in my project it is part of the configuration of COM ports that is ideal, only they have it working, and for some reason I don't. Thank you in advance  

0 Kudos
Message 6 of 7
(1,425 Views)

@Andrey_26_Sarvn  ha scritto:

 I'm sorry... but what do you mean by leaving the Device name field empty? And initially I forgot to say, I was guided by a ready-made example from LabWindows, Serial.cws and wanted to do something similar, because in my project it is part of the configuration of COM ports that is ideal, only they have it working, and for some reason I don't. Thank you in advance  


I understand this, but the example retrieves from the same control both port number and device name, and they match. In your case they don't.

 

If you look at the help for OpenComConfig you'll see this (red highlight is mine):

deviceName char [] The name of the COM port to open, passed as an ASCII string.

For example, deviceName can be "COM1" for COM port 1 under Windows using comm.drv.

(Linux) For example, deviceName can be "/dev/ttyS0" for COM port 1.

comm.drv, which comes with Windows, recognizes COM1 through COM4 only. Refer to the documentation for your Expanded Com Port Board for Device Names beyond COM4.

If you pass a NULL pointer or an empty string for deviceName, the library uses device names depending on the portNumber you specify. The following table shows the syntax for opening ports one through four. You can follow this model to open higher-numbered ports.

portNumber deviceName under Windows deviceName under Linux
1 "COM1" "/dev/ttyS0"
2 "COM2" "/dev/ttyS1"
3 "COM3" "/dev/ttyS2"
4 "COM4" "/dev/ttyS3"

 

That is to say, I was suggesting to open the port this way:

 RS232Error = OpenComConfig (comport, "", baudrate, parity, databits, stopbits, inputq, outputq);



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
0 Kudos
Message 7 of 7
(1,415 Views)