dyc 32
New Member
Can somebody help? Really need help.
I got this sample from internet but there some parts I could not understand well why we have to use the thing for ..
Hope can seek some advice through this forum...thanks. . - Private Sub Receiver(ByVal sender As Object, ByVal e As SerialDataReceivedEventArgs) Handles COMPort.DataReceived
-
' Note this subroutine is executed on the serial port thread - not the UI thread.
-
Dim RXByte, Nibble As Byte
-
Dim RXArray(2047) As Char
-
Dim I As Integer = 0
-
Do
-
RXByte = COMPort.ReadByte
-
Nibble = (RXByte >> 4) + 48 ' Convert received byte to Hex
-
-
If Nibble > 57 Then
-
Nibble = Nibble + 7
-
End If
-
RXArray(I) = Chr(Nibble)
-
I = I + 1
-
Nibble = (RXByte And 15) + 48
-
If Nibble > 57 Then
-
Nibble = Nibble + 7
-
End If
-
RXArray(I) = Chr(Nibble)
-
I = I + 1
-
RXArray(I) = " "
-
I = I + 1
-
SpaceCount = (SpaceCount + 1) And 31 ' Insert spaces and CRLF for better readability
-
If SpaceCount = 0 Then ' Insert CRLF after 32 numbers
-
RXArray(I) = Chr(13) ' CR
-
I = I + 1
-
RXArray(I) = Chr(10) ' LF
-
I = I + 1
-
Else
-
If (SpaceCount And 3) = 0 Then ' Insert two extra spaces for each 4 numbers
-
RXArray(I) = " "
-
I = I + 1
-
RXArray(I) = " "
-
I = I + 1
-
End If
-
End If
-
Loop Until (COMPort.BytesToRead = 0)
-
Dim RxString As New String(RXArray, 0, I) ' Convert the first part of the Char Array to a String
-
' Put a message with a delegate, which points to the display routine and holds the RxString,
-
' on the message queue and return immediately.
-
Me.BeginInvoke(New StringSubPointer(AddressOf Display), RxString)
-
End Sub
-
-
' Text display routine, which appends the received string to any text in the Received TextBox.
-
-
Private Sub Display(ByVal Buffer As String)
-
Received.AppendText (Buffer)
-
End Sub
-
-
' Transmitter subroutine.
-
-
Private Sub Transmitter(ByVal sender As Object, ByVal e As EventArgs) Handles SendButton.Click
-
Received.AppendText ("TX" & vbCrLf) ' Switch to a new line after every transmission
-
SpaceCount = 0
-
Dim TextString As String
-
Dim TXArray(2047) As Byte
-
Dim I As Integer
-
Dim J As Integer = 0
-
Dim Ascii As Boolean = False
-
Dim Quote As Boolean = False
-
Dim Temp As Boolean
-
Dim Second As Boolean = False
-
Dim TXByte As Byte = 0
-
Dim CharByte As Byte
-
-
If COMPort.IsOpen Then
-
TextString = Transmitted.Text
-
For I = 0 To TextString.Length - 1
-
CharByte = Asc(TextString.Chars(I))
-
If CharByte = 34 Then ' If " Then
-
Temp = Ascii
-
Ascii = Ascii Or Quote
-
Quote = Not (Temp And Quote)
-
Else
-
Ascii = Ascii Xor Quote
-
Quote = False
-
End If
-
If Not Quote Then
-
If Ascii Then
-
TXArray(J) = CharByte
-
J = J + 1
-
Else
-
If (CharByte <> 32) And (CharByte <> 10) And (CharByte <> 13) Then ' Skip spaces, LF and CR
-
CharByte = (CharByte - 48) And 31 ' And 31 makes it case insensitive
-
If CharByte > 16 Then
-
CharByte = CharByte - 7
-
End If
-
If Second Then
-
TXArray(J) = TXByte + CharByte
-
Second = False
-
J = J + 1
-
Else
-
TXByte = CharByte << 4
-
Second = True
-
End If
-
End If
-
End If
-
End If
-
Next
-
Try
-
COMPort.Write(TXArray, 0, J)
-
Catch ex As Exception
-
MsgBox (ex.Message & " Check CTS signal or set Flow Control to None.")
-
End Try
-
Else
-
thanks again..
-
MsgBox ("COM port is closed. Please select a COM port")
-
End If
-
End Sub
-
1 1586 dyc 32
New Member RXByte = COMPort.ReadByt e
How we can noe how byte it is for the COMPort, in this case the COMPort is a variable name for the serial Port..
thanks..I totally lsot...
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: PHPkemon |
last post by:
Hi there,
A few weeks ago I made a post and got an answer which seemed very logical.
Here's part of the post:
PHPkemon wrote:
> I think I've figured out how to do the main things like storing products
in
|
by: d.warnermurray |
last post by:
I am doing a project for school that involves creating help files for a html
authoring tool.
If you could help me with answers to some questions it would really help.
1. What tasks do you expect an html authoring tool to help you accomplish?
2. What do you expect from online help for a html authoring tool?
3. What audience do you think a freeware html authoring tool is directed
towards?
|
by: Mark Reed |
last post by:
Hi all,
I am trying to learn a little about programming (I know next to nothing
so far) and have found some code which hides the toolbars. However, this bit
of code is a little too effective and hides all of them including hiding the
database window, disabling menu changes. What I am after is the same effect
as disabling all the check boxes in startup which still leaves 'File',
'Edit', 'Insert','Records','Window' &'Help'. I want to do this...
|
by: dixie |
last post by:
Help, I'm really out of my depth here (not unusual I hear you say :-). I
have just installed HTML Help in an application. I told it in the Project
Properties the path to the help file. I then type in a command line that
runs the help in the correct Context from a button on each form. It all
worked fine - HERE.
The problem is that when I sent it out to a site, the help file was not able
to be accessed because it was my path in the...
|
by: Timothy Shih |
last post by:
Hi, I am trying to figure out how to use unmanaged code using P/Invoke. I
wrote a simple function which takes in 2 buffers (one a byte buffer, one a
char buffer) and copies the contents of the byte buffer into the character
pointer. The code looks like the following:
#include <stdio.h>
#include <stdlib.h>
#include "stdafx.h"
BOOL APIENTRY DllMain( HANDLE hModule,
DWORD ul_reason_for_call,
| |
by: Jason |
last post by:
Hi,
I was wondering if any could point me to an example or give me ideas on how
to dynamically create a form based on a database table? So, I would have a
table designed to tell my application to create certain textboxes, labels,
and combo boxes? Any ideas would be appreciated.
Thanks
|
by: Allen |
last post by:
I have a class that returns an arraylist. How do I fill a list box from what
is returned? It returns customers which is a arraylist but I cant seem to
get the stuff to fill a list box. I just learning and really need some help
bad.
Public Shared Function GetAll() As ArrayList
Dim dsCustomer As New DataSet()
Dim sqlQuery As String = "SELECT Name, Address, PhoneNo " & _
"FROM CustomerTable"
Try
|
by: inkexit |
last post by:
I need help figuring out what is wrong with my code. I posted here a
few weeks ago with some code about creating self similar melodies in
music. The coding style I'm being taught is apparently a lot different
from what the pros around here use. I really need help with debugging
some program errors more than anything, even though my coding style
might not be perfect.
Anyway here is my code. About the only things that work right are...
|
by: glenn123 |
last post by:
Hi, i am just about out of time to produce a working jukebox which has to perform these functions: to play music files when a track is chosen from a list which when the user presses the change genre button the list is populated with a list of that genre.
I have got the interface done to satisfaction, my problem is that when i press the change genre button nothing happens and when i select a track to play from the list which is setvisible and...
|
by: JonathanOrlev |
last post by:
Hello everybody,
I wrote this comment in another message of mine, but decided to post it
again as a standalone message.
I think that Microsoft's Office 2003 help system is horrible, probably
the worst I
ever seen.
I almost cannot find anything I need, including things I
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
| |
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |