Serial port receive format? 
Author Message
 Serial port receive format?

Sorry to post yet again about the serial port but i am a loss. I am
sending three bytes of data to a machine which should un return
respond with a further three bytes. I have so far seen various things
back from the machine, using the mscomm.input command, such as 3 weird
characters or three solid black lines when the input mode is set to
binary. Is this some kind of code or just a load of rubbish. Any help
would be greatly appreciated as this is currently driving me mad!

Thanks

Chris



Tue, 13 Apr 2004 17:34:00 GMT  
 Serial port receive format?
It depends if the bytes are ASCII viewable characters. You may have problems
viewing ASCII charaters 32<  or >127.

Eg 32 dec = a space  and   65 dec = "A"  66 = "B"

You may need to convert the btyes in to a dec or hex string.

OR ...
You have the wrong baud rate, number of bits, parity, number of stop bits.

Regards
JG


Quote:
> Sorry to post yet again about the serial port but i am a loss. I am
> sending three bytes of data to a machine which should un return
> respond with a further three bytes. I have so far seen various things
> back from the machine, using the mscomm.input command, such as 3 weird
> characters or three solid black lines when the input mode is set to
> binary. Is this some kind of code or just a load of rubbish. Any help
> would be greatly appreciated as this is currently driving me mad!

> Thanks

> Chris



Tue, 13 Apr 2004 19:42:26 GMT  
 Serial port receive format?

Quote:
>Sorry to post yet again about the serial port but i am a loss. I am
>sending three bytes of data to a machine which should un return
>respond with a further three bytes. I have so far seen various things
>back from the machine, using the mscomm.input command, such as 3 weird
>characters or three solid black lines when the input mode is set to
>binary. Is this some kind of code or just a load of rubbish. Any help
>would be greatly appreciated as this is currently driving me mad!

>Thanks

>Chris

I see from earlier posts that you are sending non-printable characters
to the device, so it's not surprising if you get non-printable
characters back.
Do you khow what you should be getting?
Have you tried using the Asc, AscB, AscW functions?


Tue, 13 Apr 2004 19:59:03 GMT  
 Serial port receive format?

Quote:

> Sorry to post yet again about the serial port but i am a loss. I am
> sending three bytes of data to a machine which should un return
> respond with a further three bytes. I have so far seen various things
> back from the machine, using the mscomm.input command, such as 3 weird
> characters or three solid black lines when the input mode is set to
> binary. Is this some kind of code or just a load of rubbish. Any help
> would be greatly appreciated as this is currently driving me mad!

Hi Chris-

Try playing with this. It should give you a few ideas. It's basically an
expanded version of what Frank Adam suggested earlier. Text1.Text is
your "input data", and it preloads with a string of low value ASCII
characters. Text2.Text shows the result after conversion with 4
different formatting options. This was written in VB4/32, so you may
have to tweak it for later versions. It is assumed that this is NOT
Unicode, but just simple ASCII bytes.

'----------------{COPY EVERYTHING BELOW THIS LINE}----------
VERSION 4.00
Begin VB.Form Form1
   Caption         =   "Data Byte Conversion Demo"
   ClientHeight    =   3585
   ClientLeft      =   1965
   ClientTop       =   2925
   ClientWidth     =   6090
   Height          =   3990
   Left            =   1905
   LinkTopic       =   "Form1"
   ScaleHeight     =   3585
   ScaleWidth      =   6090
   Top             =   2580
   Width           =   6210
   Begin VB.Frame Frame1
      Caption         =   "Byte Formatting Options:"
      BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
         Name            =   "MS Sans Serif"
         Size            =   8.25
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   675
      Left            =   60
      TabIndex        =   4
      Top             =   2280
      Width           =   5895
      Begin VB.OptionButton optFormat
         Caption         =   "Arrows"
         BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
            Name            =   "MS Sans Serif"
            Size            =   8.25
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   255
         Index           =   0
         Left            =   60
         TabIndex        =   8
         Top             =   300
         Value           =   -1  'True
         Width           =   960
      End
      Begin VB.OptionButton optFormat
         Caption         =   "Packed"
         BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
            Name            =   "MS Sans Serif"
            Size            =   8.25
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   255
         Index           =   3
         Left            =   4620
         TabIndex        =   7
         Top             =   300
         Width           =   1020
      End
      Begin VB.OptionButton optFormat
         Caption         =   "Space"
         BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
            Name            =   "MS Sans Serif"
            Size            =   8.25
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   255
         Index           =   2
         Left            =   3300
         TabIndex        =   6
         Top             =   300
         Width           =   915
      End
      Begin VB.OptionButton optFormat
         Caption         =   "Brackets"
         BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
            Name            =   "MS Sans Serif"
            Size            =   8.25
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   255
         Index           =   1
         Left            =   1740
         TabIndex        =   5
         Top             =   300
         Width           =   1080
      End
   End
   Begin VB.CommandButton Command2
      Caption         =   "Clear"
      BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
         Name            =   "MS Sans Serif"
         Size            =   8.25
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   435
      Left            =   1200
      TabIndex        =   3
      Top             =   3060
      Width           =   1095
   End
   Begin VB.CommandButton Command1
      Caption         =   "Convert"
      BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
         Name            =   "MS Sans Serif"
         Size            =   8.25
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   435
      Left            =   120
      TabIndex        =   2
      Top             =   3060
      Width           =   1035
   End
   Begin VB.TextBox Text2
      BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
         Name            =   "MS Sans Serif"
         Size            =   8.25
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   1395
      Left            =   60
      MultiLine       =   -1  'True
      ScrollBars      =   2  'Vertical
      TabIndex        =   1
      Top             =   780
      Width           =   5895
   End
   Begin VB.TextBox Text1
      BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
         Name            =   "MS Sans Serif"
         Size            =   8.25
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   555
      Left            =   60
      TabIndex        =   0
      Top             =   60
      Width           =   5835
   End
End
Attribute VB_Name = "Form1"
Attribute VB_Creatable = False
Attribute VB_Exposed = False
Private Sub Command1_Click()
a$ = Text1.Text
b$ = ""
For Index = 0 To 3
    If optFormat(Index).Value = True Then FC = Index
Next Index
    If FC = 0 Then fc1 = "<": fc2 = ">"
    If FC = 1 Then fc1 = "[": fc2 = "]"
    If FC = 2 Then fc1 = " ": fc2 = ""
    If FC = 3 Then fc1 = "": fc2 = ""
For i = 1 To Len(a$)
    b$ = b$ & fc1 & Right$("00" & LTrim$(Hex$(Asc(Mid$(a$, i, 1)))), 2)
& fc2
Next i
Text2.Text = b$
End Sub
Private Sub Command2_Click()
Text1.Text = ""
Text2.Text = ""
End Sub
Private Sub Form_Load()
a$ = Chr$(2) & Chr$(12) & Chr$(5) & Chr$(7) & Chr$(18) & Chr$(3) &
Chr$(22) & Chr$(31)
Text1.Text = a$
End Sub
'----------------{COPY EVERYTHING ABOVE THIS LINE}----------

Paste this into Notepad and save as 'ByteConv.Frm'

Good Luck,

Randy Barrow
--

==============================================
Please remove NOSPAM from address for replies
==============================================



Tue, 13 Apr 2004 20:38:13 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. Receiving from serial port in qb4.5

2. Receiving ASCII Values Through Serial Port

3. Receiving binary data from a serial port

4. mscomm - send/receive from serial port

5. Receive data thru the serial port.

6. View text received on serial port

7. Sendind and Receiving data from a serial port in Visual Basic

8. I/O port, Parallel port, Serial port

9. qb45 and SERIAL strange SERIAL port protocol

10. serial printer on serial port

11. serial printer on serial port

12. Future of Serial Ports vs USB Ports

 

 
Powered by phpBB® Forum Software