From: Michael on
Hi,

How do you output binary from the serial prot using MSCOMM? I need to send
1011010000000100 to a device.

Thanks,

Michael


From: btpanek09@yahoo.com on

Michael wrote:
> Hi,
>
> How do you output binary from the serial prot using MSCOMM? I need to send
> 1011010000000100 to a device.
>
> Thanks,
>
> Michael

This binary value is represented by the Hex value B404 as shown, each
4 bits translates to a Hex digit.
B 4 0 4
1011 0100 0000 0100

Set MSCOMM InputMode to 1-ComInputModeBinary
create a byte buffer that will contain 2 bytes
Dim OutBuf(0 to 1) as Byte
OutBuf(0) = &HB4
OutBuf(1) = &H04
Then send the message....
MSCOMM.Output OutBuf

Of course you must Initialize and Open the MSCOMM first.

From: Henning on

"Michael" <mqiqcqhqaqeqlqhqiqmqsq(a)qbqlquqeqyqoqnqdqeqrq.qcqoq.quqkq> skrev i
meddelandet news:N8hJg.88349$fV1.23224(a)fe1.news.blueyonder.co.uk...
> Hi,
>
> How do you output binary from the serial prot using MSCOMM? I need to send
> 1011010000000100 to a device.
>
> Thanks,
>
> Michael
>
You can only output bytes of data, in your case two bytes as &HB4; &H04.
Something like
s$ = Chr$(&HB4) & Chr$(&H4)
Print#comport, s$;

Depends also on what 'device' is like.

/Henning


From: Michael on

"Henning" <computer_hero(a)coldmail.com> wrote in message
news:44f5b744$0$32154$57c3e1d3(a)news3.bahnhof.se...
>
> "Michael" <mqiqcqhqaqeqlqhqiqmqsq(a)qbqlquqeqyqoqnqdqeqrq.qcqoq.quqkq> skrev
> i
> meddelandet news:N8hJg.88349$fV1.23224(a)fe1.news.blueyonder.co.uk...
>> Hi,
>>
>> How do you output binary from the serial prot using MSCOMM? I need to
>> send
>> 1011010000000100 to a device.
>>
>> Thanks,
>>
>> Michael
>>
> You can only output bytes of data, in your case two bytes as &HB4; &H04.
> Something like
> s$ = Chr$(&HB4) & Chr$(&H4)
> Print#comport, s$;
>
> Depends also on what 'device' is like.
>
> /Henning
>
>
Thanks for the replies,

Michael


From: Michael on

<btpanek09(a)yahoo.com> wrote in message
news:1156953650.401271.48120(a)p79g2000cwp.googlegroups.com...
>
> Michael wrote:
>> Hi,
>>
>> How do you output binary from the serial prot using MSCOMM? I need to
>> send
>> 1011010000000100 to a device.
>>
>> Thanks,
>>
>> Michael
>
> This binary value is represented by the Hex value B404 as shown, each
> 4 bits translates to a Hex digit.
> B 4 0 4
> 1011 0100 0000 0100
>
> Set MSCOMM InputMode to 1-ComInputModeBinary
> create a byte buffer that will contain 2 bytes
> Dim OutBuf(0 to 1) as Byte
> OutBuf(0) = &HB4
> OutBuf(1) = &H04
> Then send the message....
> MSCOMM.Output OutBuf
>
> Of course you must Initialize and Open the MSCOMM first.
>

I've hit another slight problem. Once the device has received the data it
sends back a checksum "&H6A", if the program doesn't receive that it resends
the data. This is what I have so far:

Dim outbuf2 As String
outbuf2 = Hex(MSComm1.Input)
If outbuf2 = &H6A Then
Timer1.Enabled = False
'carry on with program
Else 'resend the data
MSComm1.Output = Outbuf
End If

When I run the program I get a Mismatch error on the line outbuf2 =
Hex(MSComm1.Input). Can someone please explain where I'm going wrong? I
thought letters and numbers could be converted to hexadecimals?

Michael


 |  Next  |  Last
Pages: 1 2
Prev: Printer-Object again
Next: What is this error ???