> вопрос программистам (Visual Basic), управление через RS 232 (COM)
 dad
 Posted: 10-11-2003, 00:18 (post 1, #189923)
Quote Post

Unregistered


в этом деле я новис, поэтому приму любую помощь.

задача - управление приборами через RS232 (COM) приложением на Visual Basicе. Раньше на нем никогда не прогал, а сделать нужно в ближайшие сроки. Как решить эту задачу на basic, pascal, c++ знаю...

вобщем необходимо выполнять примитивные функции:
1. Активировать СОМ с необходимыми параметрами.
2. Отправлять команду
3. Считывать ответ в файл.
все.

заранее спасибо!
Top Bottom
 Sidorini Member is Offline
 Posted: 10-11-2003, 00:34 (post 2, #189929)
Quote Post

Главный Колобок
Group: Global Moders
Group: Global Moders
Posts: 7618
Используй контроль MScomm (клик правой кнопкой мыши на General слева, выбрать Components -> Microsoft Comm Control).
PM Email Poster ICQ MSN
Top Bottom
 dad
 Posted: 10-11-2003, 00:52 (post 3, #189936)
Quote Post

Unregistered


Sidorini
спасибо!
а где можно достать примеры кодов не подскажешь? а то без поллитра так не разобраться... sad.gif
Top Bottom
 Sidorini Member is Offline
 Posted: 10-11-2003, 01:19 (post 4, #189953)
Quote Post

Главный Колобок
Group: Global Moders
Group: Global Moders
Posts: 7618
QUOTE (dad @ 09-11-2003, 23:52)
Sidorini
спасибо!
а где можно достать примеры кодов не подскажешь? а то без поллитра так не разобраться... sad.gif

Просто объяви поиск на MScomm.
А пока маленький пример :

CODE

 If MSComm1.PortOpen Then
    MSComm1.PortOpen = False
 End If
MSComm1.Settings = "9600,n,8,1"
MSComm1.PortOpen = True


Так мы открываем порт с установками:
Baud Rate - 9600
No Parity
8 data bits
1 stop bit
PM Email Poster ICQ MSN
Top Bottom
 dad
 Posted: 10-11-2003, 01:27 (post 5, #189957)
Quote Post

Unregistered


еще раз спасибо, уже там роюсь.
наберусь наглости и спрошу, а чтобы вывести данные во внешний файл (текстовый или АSCII data) что поискать? smile.gif
Top Bottom
 Sidorini Member is Offline
 Posted: 10-11-2003, 01:44 (post 6, #189963)
Quote Post

Главный Колобок
Group: Global Moders
Group: Global Moders
Posts: 7618
Open pathname For mode [Access access] [lock] As [#]filenumber [Len=reclength]

The Open statement syntax has these parts:


pathname - Required. String expression that specifies a file name — may include directory or folder, and drive.
mode - Required. Keyword specifying the file mode: Append, Binary, Input, Output, or Random. If unspecified, the file is opened for Random access.
access - Optional. Keyword specifying the operations permitted on the open file: Read, Write, or Read Write.
lock - Optional. Keyword specifying the operations restricted on the open file by other processes: Shared, Lock Read, Lock Write, and Lock Read Write.
filenumber - Required. A valid file number in the range 1 to 511, inclusive. Use the FreeFile function to obtain the next available file number.
reclength - Optional. Number less than or equal to 32,767 (bytes). For files opened for random access, this value is the record length. For sequential files, this value is the number of characters buffered.

MSDN ©

Пример:

CODE

Open C:\... For Output Access Write As #1
     Print #1, ....
Close #1
PM Email Poster ICQ MSN
Top Bottom
 dad
 Posted: 10-11-2003, 03:56 (post 7, #189992)
Quote Post

Unregistered


Sidorini, о похоже на квикбейсик newest/w00t.gif

очень признателен, спасибо за помощь!!! smile.gif
Top Bottom
 Sidorini Member is Offline
 Posted: 11-11-2003, 06:05 (post 8, #190252)
Quote Post

Главный Колобок
Group: Global Moders
Group: Global Moders
Posts: 7618
QUOTE (dad @ 10-11-2003, 02:56)
очень признателен, спасибо за помощь!!! smile.gif

dad - Не за что smile.gif
PM Email Poster ICQ MSN
Top Bottom
 dad
 Posted: 12-11-2003, 01:10 (post 9, #190543)
Quote Post

Unregistered


Sidorini
уже разобрался, все пашет, все пучком smile.gif
сенкс!
Top Bottom
Topic Options