I have a device in the field that I access by the stream method.
I open the Stream and do the following:
1. stream.write a character to the device.
2. stream.read the information from the device.
The problem is that when I am debugging and step through the code there is a long enough pause that I recieve the entire string. If I just run it, I only get the 1st character. I have attached the code below. - Public Class Form1
-
Inherits System.Windows.Forms.Form
-
-
'Setup up a new socket
-
Public tClient As New System.Net.Sockets.TcpClient()
-
-
' Get a client stream for reading and writing.
-
Public stream As NetworkStream
-
Public str_Output_message As String
-
Public IP_Address As String = xxx.xxx.xxx.xxx
-
Public Port_Number As Integer = xxxxx
-
-
Public Sub i_Comm_Initilization()
-
-
'****************Should these be set by the Database?****************
-
tClient.ReceiveBufferSize = (256)
-
tClient.ReceiveTimeout = 3000
-
tClient.SendTimeout = 1000
-
'Create a TcpClient.
-
tClient.Connect(IP_Address, Port_Number)
-
-
' Get a client stream for reading and writing.
-
stream = tClient.GetStream()
-
-
'get the information from the device
-
i_Read_Device_xmitB()
-
-
'Delete the recordstore and close the connection to the field device
-
i_delete_recordstore()
-
i_Close_Connection()
-
-
End Sub
-
Public Sub i_Read_Device_xmitB()
-
-
'Set the Output message
-
str_Output_message = "b"
-
-
Dim byt_receive_buffer(tClient.ReceiveBufferSize) As Byte
-
-
' Translate the message to be transmitted into ASCII and store it as a Byte array.
-
byt_array_data = Encoding.ASCII.GetBytes(str_Output_message)
-
-
str_returndata = ""
-
-
If stream.CanWrite And stream.CanRead Then
-
-
' Do a simple write.
-
' Send the message to the connected TcpServer.
-
stream.Write(byt_array_data, 0, byt_array_data.Length)
-
-
stream.Read(bytes, 0, CInt(tClient.ReceiveBufferSize))
-
-
' Output the data received from the host to the console.
-
str_returndata = Encoding.ASCII.GetString(bytes)
-
-
stream.Write(byt_array_data, 0, byt_array_data.Length)
-
-
'Call the Data Breakout Routine
-
i_Data_Breakout()
3 1358 RedSon 5,000
Recognized Expert Expert
Might be better to post this in the VB forum.
Might be better to post this in the VB forum.
Someone must have moved it. Where was it originally?
RedSon 5,000
Recognized Expert Expert
Someone must have moved it. Where was it originally?
Where else? c/c++
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: da Vinci |
last post by:
OK, this has got to be a simple one and yet I cannot find the answer
in my textbook.
How can I get a simple pause after an output line, that simply waits
for any key to be pressed to move on?
Basically: "Press any key to continue..."
I beleive that I am looking for is something along the lines of a....
|
by: arajunk |
last post by:
I was looking around for some code for a special purpose and found
this. Seems it should print "here we go" , pause 5 seconds, print "now
we are back". Instead, it pauses 5 seconds before printing both lines
with no pause between. Can someone please explain why it behaves that
way. I know in the case of "setTimeout" the only thing affected is the
function, etc. appearing as "setTimeout" arguments. But, this is just
straight code.
...
|
by: sandy |
last post by:
I need (okay, I want) to make a dynamic array of my class 'Directory',
within my class Directory (Can you already smell disaster?)
Each Directory can have subdirectories so I thought to put these in an
array. The application compiles but aborts without giving me any useful
information.
What I suspect is happening is infinite recursion. Each Directory
object creates an array of Subdirectories each of which has an array of...
|
by: paraidy |
last post by:
Hi all, as from object i need to read all byte from a file example c:
\myphoto.jpg and recreate the file with another name to another
directory c:\photo\recreatedphoto.jpg can someone write a small
example to do it?
thx a lot men :)
|
by: markclinn |
last post by:
I have a device in the field that I access by the stream method.
I open the Stream and do the following:
1. stream.write a character to the device.
2. stream.read the information from the device.
The problem is that when I am debugging and step through the code there is a long enough pause that I recieve the entire string. If I just run it, I only get the 1st character. I have attached the code below.
Public Class Form1
Inherits...
| |
by: Robert Dailey |
last post by:
Hi,
I'm trying to create a Python equivalent of the C++ "ifstream" class,
with slight behavior changes.
Basically, I want to have a "filestream" object that will allow you to
overload the '<<' and '>>' operators to stream out and stream in data,
respectively. So far this is what I have:
class filestream:
|
by: Vlad |
last post by:
I am having problems using the file.create method within a function
that is called when looping through an array of filepaths.
If I call my function with a hardcoded file path --C:\Temp.txt the
function creates the file as expected.
When I loop through my array I get the error - "ArgumentException was
unhandled - Illegal characters in path"
The value "C:\Temp.txt" is the first value in the array - as it works
|
by: Nitin Mahajan |
last post by:
Guys
Is there a way in C# to create a word object directly from a memory
stream without passing that to hard disk (file stream). I think it
doesn't makes sense to create a file just to read it again in to word
object. If some one has some brilliant idea please share.
In a nutshell this is what I'm currently doing
ByteArray --File Stream --Word Object
and this I want to do
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
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: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
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: 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...
| |