Модераторы: Akina
  

Поиск:

Ответ в темуСоздание новой темы Создание опроса
> нулевые байты в com порт, пчему terminal не читает 00 
:(
    Опции темы
монах
Дата 9.10.2006, 15:55 (ссылка) | (нет голосов) Загрузка ... Загрузка ... Быстрая цитата Цитата


Новичок



Профиль
Группа: Участник
Сообщений: 26
Регистрация: 3.1.2004

Репутация: нет
Всего: нет



Суть такая, устройство передает инфу в СОМ порт
а программа ловит эти моменты:
Код

Private Sub MSComm1_OnComm()
Dim Buffer As Variant
Open "ozu.bin" For Binary As #1
Select Case MSComm1.CommEvent
    Case comEvReceive
        Buffer = MSComm1.Input
        Put #1, Text5, Buffer
End Select
Close #1
End Sub

(текст5---цифра)
однако, если устройство передает 00, то программа делает вид, что ничего не происходит!

подскажите, как уловить этот момент?

и ещё! почему при получении байта и записи его в файл
Код

Put #1, Text5, Buffer

в файле оказывается:
11 20 01 00 01 00 00 00 00 00 00 00 хх
хх - нужный байт
как этого избежать?
PM MAIL   Вверх
Akina
Дата 9.10.2006, 17:29 (ссылка) | (нет голосов) Загрузка ... Загрузка ... Быстрая цитата Цитата


Советчик
****


Профиль
Группа: Модератор
Сообщений: 20581
Регистрация: 8.4.2004
Где: Зеленоград

Репутация: 34
Всего: 454



Внимательно читаем MSDN про Put Statement. Обращаем внимание на типы и поведение оператора в зависимости от типов аргументов.


--------------------
 О(б)суждение моих действий - в соответствующей теме, пожалуйста. Или в РМ. И высшая инстанция - Администрация форума.

PM MAIL WWW ICQ Jabber   Вверх
монах
Дата 10.10.2006, 12:26 (ссылка) | (нет голосов) Загрузка ... Загрузка ... Быстрая цитата Цитата


Новичок



Профиль
Группа: Участник
Сообщений: 26
Регистрация: 3.1.2004

Репутация: нет
Всего: нет



чвот я не нашел на сайте MSDN оператора put! get есть, а put  нету??
PM MAIL   Вверх
cardinal
Дата 10.10.2006, 13:41 (ссылка) | (нет голосов) Загрузка ... Загрузка ... Быстрая цитата Цитата


Инженер
****


Профиль
Группа: Экс. модератор
Сообщений: 6003
Регистрация: 26.3.2002
Где: Германия

Репутация: 19
Всего: 99



Цитата(MSDN)

Put Statement
      
Writes data from avariable to a disk file.

Syntax

Put [#]filenumber, [recnumber], varname

The Put statement syntax has these parts:

Part Description 
filenumber Required. Any validfile number. 
recnumber Optional. Variant (Long). Record number (Random mode files) or byte number (Binary mode files) at which writing begins. 
varname Required. Name of variable containing data to be written to disk. 


Remarks

Data written with Put is usually read from a file with Get.

The first record or byte in a file is at position 1, the second record or byte is at position 2, and so on. If you omit recnumber, the next record or byte after the last Get or Put statement or pointed to by the last Seek function is written. You must include delimiting commas, for example:

Put #4,,FileBuffer

For files opened in Random mode, the following rules apply: 

If the length of the data being written is less than the length specified in the Len clause of the Open statement, Put writes subsequent records on record-length boundaries. The space between the end of one record and the beginning of the next record is padded with the existing contents of the file buffer. Because the amount of padding data can't be determined with any certainty, it is generally a good idea to have the record length match the length of the data being written. If the length of the data being written is greater than the length specified in the Len clause of the Open statement, an error occurs.


If the variable being written is a variable-length string, Put writes a 2-byte descriptor containing the string length and then the variable. The record length specified by the Len clause in the Open statement must be at least 2 bytes greater than the actual length of the string.


If the variable being written is aVariant of anumeric type, Put writes 2 bytes identifying the VarType of the Variant and then writes the variable. For example, when writing a Variant of VarType 3, Put writes 6 bytes: 2 bytes identifying the Variant as VarType 3 (Long) and 4 bytes containing the Long data. The record length specified by the Len clause in the Open statement must be at least 2 bytes greater than the actual number of bytes required to store the variable. 
Note   You can use the Put statement to write a Variantarray to disk, but you can't use Put to write a scalar Variant containing an array to disk. You also can't use Put to write objects to disk. 

If the variable being written is a Variant of VarType 8 (String), Put writes 2 bytes identifying the VarType, 2 bytes indicating the length of the string, and then writes the string data. The record length specified by the Len clause in the Open statement must be at least 4 bytes greater than the actual length of the string.


If the variable being written is a dynamic array, Put writes a descriptor whose length equals 2 plus 8 times the number of dimensions, that is, 2 + 8 * NumberOfDimensions. The record length specified by the Len clause in the Open statement must be greater than or equal to the sum of all the bytes required to write the array data and the array descriptor. For example, the following array declaration requires 118 bytes when the array is written to disk.
Dim MyArray(1 To 5,1 To 10) As Integer

The 118 bytes are distributed as follows: 18 bytes for the descriptor (2 + 8 * 2), and 100 bytes for the data (5 * 10 * 2).


If the variable being written is a fixed-size array, Put writes only the data. No descriptor is written to disk.


If the variable being written is any other type of variable (not a variable-length string or a Variant), Put writes only the variable data. The record length specified by the Len clause in the Open statement must be greater than or equal to the length of the data being written.


Put writes elements ofuser-defined types as if each were written individually, except there is no padding between elements. On disk, a dynamic array in a user-defined type written with Put is prefixed by a descriptor whose length equals 2 plus 8 times the number of dimensions, that is, 2 + 8 * NumberOfDimensions. The record length specified by the Len clause in the Open statement must be greater than or equal to the sum of all the bytes required to write the individual elements, including any arrays and their descriptors. 
For files opened in Binary mode, all of the Random rules apply, except: 

The Len clause in the Open statement has no effect. Put writes all variables to disk contiguously; that is, with no padding between records.


For any array other than an array in a user-defined type, Put writes only the data. No descriptor is written.


Put writes variable-length strings that are not elements of user-defined types without the 2-byte length descriptor. The number of bytes written equals the number of characters in the string. For example, the following statements write 10 bytes to file number 1:
VarString$ = String$(10," ")
Put #1,,VarString$



--------------------
Немецкая оппозиция потребовала упростить натурализацию иммигрантов
В моем блоге: Разные истории из жизни в Германии

"Познание бесконечности требует бесконечного времени, а потому работай не работай - все едино".  А. и Б. Стругацкие
PM   Вверх
  
Ответ в темуСоздание новой темы Создание опроса
Правила форума "VB6"
Akina

Запрещается!

1. Публиковать ссылки на вскрытые компоненты

2. Обсуждать взлом компонентов и делиться вскрытыми компонентами

  • Литературу по VB обсуждаем здесь
  • Действия модераторов можно обсудить здесь
  • С просьбами о написании курсовой, реферата и т.п. обращаться сюда
  • Вопросы по реализации алгоритмов рассматриваются здесь
  • Используйте теги [code=vb][/code] для подсветки кода. Используйтe чекбокс "транслит" (возле кнопок кодов) если у Вас нет русских шрифтов.


Если Вам понравилась атмосфера форума, заходите к нам чаще! С уважением, Akina.

 
0 Пользователей читают эту тему (0 Гостей и 0 Скрытых Пользователей)
0 Пользователей:
« Предыдущая тема | VB6 | Следующая тема »


 




[ Время генерации скрипта: 0.1001 ]   [ Использовано запросов: 22 ]   [ GZIP включён ]


Реклама на сайте     Информационное спонсорство

 
По вопросам размещения рекламы пишите на vladimir(sobaka)vingrad.ru
Отказ от ответственности     Powered by Invision Power Board(R) 1.3 © 2003  IPS, Inc.