VS 2008 TCP Control - Mixing Bytes With String
Aug 8, 2010
I am currently writing a VB.net app to control an Integra AV receiver. I have success controlling it via Serial, but it also has a network port for TCP control. I can control it using CommandFusion iPhone app but am now wanting to create a windows app to control it. I have created client/server software that I use to talk from one PC to the which works well. So I am going to use the same client software to talk to the AV receiver. I can connect fine to it, I just haven't quite got the protocol right to actually control it.
[Code]...
View 8 Replies
ADVERTISEMENT
May 19, 2009
I have a string of bytes which I am reading from a microcontroller via a serial port which is as follows : 02 10 18 14 CB 73 43 D3 14 00 0D 00 09 00 1B 00 04 B8 3C 00 00 24 00 30 AB
I would like to write some code to place each the bytes into an array with each element of the array consisting of one byte each.
View 10 Replies
Dec 28, 2010
What exactly does this line do?
i = stream.Read(bytes, 0, bytes.Length)
Does it read the entire message string sent by the client? I have a line to write to the stream later in the code and that does not seem to be sending anything back to the client, although the code around is excuting.
i = stream.Read(bytes, 0, bytes.Length)
While (i <> 0)
Try
' Translate data bytes to a ASCII string.
[code].....
View 3 Replies
Mar 15, 2009
This is my first post as I don't like to ask questions without making sure I've exhausted all other means. I'm new to VB2008 and programming in general but I'm learning. I want to do several simple tasks. Doing each separately is easy but when I put them together I don't know what to do. For one thing to work all the code must be changed and everything else doesn't work.
1. Plot a graph of data from a DAQ. I can do this by using a Timer1_tick method and displaying the data on the linegraph as long as the timer is turned on. I've decided to stick with this method of acquisition. I want to acquire data for long periods of time (perhaps 3 hours) so a timer is pretty good. No problems here.
2. Apply a filter to remove noise from the plot dynamically as the data comes in so that I get a smooth curve instead of a jagged graph. I know I can do this with for loops if I'm using an array. But how do I do it since I'm using a timer? Here the problem begins.
3. Log every piece of the filtered data that the timer is getting to be exported to a CSV file. I learned how to do this with do loops but not with a timer or array. But I really need to use the timer this time.
4. Acquire statistics for the data like maximum value, minimum value, and average value dynamically as the data changes. I know how to do this with an array of data after all the data is acquired. But How do I do this with a timer while the data is still being collected?
5. Monitor the data coming in to execute an alarm (Or event, like stopping the acquisition) when the data coming in has plateaued and is constant (eg: The voltage I'm monitoring starts to become constant and becomes one constant value) - Ok I don't know anything about this.
6. Execute a mathematical operation on the data that has been acquired (post acquisition) like finding gradients and such. Basically this means "How do I now manipulate the data I have and where is this data stored?"
Here's my starting code that gathers data with a timer. How do I work from here?:
Private Sub Form1_FormClosing(ByVal sender As Object, ByVal e As
System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
Timer1.Enabled = False
[code]....
View 3 Replies
Feb 20, 2010
when i transfer the bytes sent by the client program to a string the string length is affected.when i put the bytes sent by the client program to a message box. it returns the corrrect text. but when i check the length it will return 8192 or higher. but the actual size is just 5.
My Code
Dim tcpClient As TcpClient = tcpListener.AcceptTcpClient()
RichTextBox1.Text = RichTextBox1.Text & vbNewLine & "Connection accepted."
' Get the stream[code]....
View 6 Replies
Oct 20, 2011
It's become a night mare. All day today I have been trying to tell the hex contents of the bytes in a string. In this case Im attentpting to detect a VBCRLF. In the debugger this in displayed as a " " and thats it no matter how I have to setting set.It makes it difficult doesn't it? The thing is that debuggers are quite capable of displaying adresses, of course this is only relevant to systems that do not change virtual addresses (which Windows does not)only physical addresses.Why is it impossible to see the values of a vbcrlf (0D0A) in a string? This sytem is becoming impossible to use.
"MODERN PROGRAMMING is deficient in elementary ways BECAUSE of problems INTRODUCED by MODERN PROGRAMMING." Me
View 3 Replies
Jun 13, 2011
I'm trying to send a 28 character string to a remote ip address and port. I've done this successfully in vb.net using the following code snippets:
Dim swon As String = "A55A6B0550000000FFFBDE0030C8"
Dim sendBytes As [Byte]()
sendBytes = Encoding.ASCII.GetBytes(swon)
netStream.Write(sendBytes, 0, sendBytes.Length)
I now have to convert this across to c++ and have the following so far:
char *swon = "A55A6B0550000000FFFBDE0030C8";
array<Byte>^ sendBuffer = gcnew array<Byte>(bufferSize);
sendBuffer = BitConverter::GetBytes( swon );
tcpStream->Write(sendBuffer, 0, sendBuffer->Length);
but am getting stuck at this point. I'm sure I'm missing a simple syntax error but I can't figure it out!To clarify, I'm not getting an error, but I don't think the string is being converted to bytes correctly as when I convert back, I just get a '01'
View 2 Replies
Jul 19, 2009
Im making a database converter (phpbb to ipb)I noticed during analysing both databases that the posts of phpbb are converted to bytes as you can c here
-- Table structure for phpbb_posts
-- ----------------------------
CREATE TABLE `phpbb_posts` ([code]....
I want to convert those to regular text again but I have no clue how to script my converter to lookup the bytes place (after 0x) converts the string (as the bytes arent in array) and where to stop converting the bytes (after the ,)then replace the bytes text by the regular text and this needs to be in a loop because all posts need to be converted to normal text.
View 5 Replies
Apr 22, 2012
I have string, what contains bytes... (Example below)
And I need convert these bytes into text... But I really don't know how...
Code (For Better understand):
CODE:
and now, how to convert it into text? (The Result text in "ProductName", BTW)(I don't want to use Hex Editor still )
View 6 Replies
Jun 9, 2011
I've got the following simple code to convert Bytes to a Hex string :-
Code:
Shared Function BytesToHex(ByVal bytes() As Byte) As String
If bytes Is Nothing Then Return ""
Dim S As String = BitConverter.ToString(bytes)
[Code].....
The HexToBytes routine obviously can take a lot longer to complete than the BytesToHex routine and is noticeably slower when dealing with a lot of data. As I'm converting a lot of hex strings back to bytes, I wondered if there was a more efficient way of doing it without looping through the whole string as I am doing?
View 18 Replies
Feb 18, 2011
Ive 2 buttons and 3 text boxes.Button 1 encrypts the data from textbox1 to bytes, converts it to string and display it in textbox2.Button 2 reads string from textbox2, converts it to bytes and decrypts it displaying it in textbox3 (textbox1 and 3 got to match).The encrypt/decrypt process works fine but the conversion from string to bytes is failing and cannot seem to find the problem. The error states that the string doesnt have the same format (Bytes(i) = Byte.Parse(Values(i))
[Code]...
View 1 Replies
Jun 2, 2011
This has to be incredibly simple, but I must not be looking in the right place.
I'm receiving this string via a FTDI usb connection:
'UUU'
I would like to receive this as a byte array of
[85,85,85]
In Python, this I would convert a string to a byte array like this: [ord(c) for c in 'UUU']
I've looked around, but haven't figured this out. How do I do this in Visual Basic?
View 2 Replies
Jan 16, 2009
first asking an question and then introducing but i kinda need some help in here.First of all im not new to VB, But i am to VB.NET and espessially socket programming.Now i need an way to send the lenght of the string being send in bytes before the string itself so <lenghtinbytes><string>.
ive tried so many things, and its possible because the client itself does it too...but just cant find an way.
[Code]...
View 13 Replies
Nov 13, 2010
I want it to do is that you input a string, then you select an algorithm (Theres only going to be one RijnDael) then you input a key, then the Initialization Vector comes from "txtIV.text" then you select the key bytes and the block bytes from the numeric up/down, then you either encrypt or decrypt.
View 1 Replies
Sep 16, 2011
Ok i am having some issues designing a base-class to handle generics.Caveat is i need to restrict the type put in as a Numeric type, specifically Int16, Int32, or Int64 (Short or Long).I know you can do Of T as {Structure} but i dont want to select the key bytes and the block bytes from the numeric up/down.
View 2 Replies
Feb 9, 2009
I am working on a project that needs to send hex bytes ie.Sub receives an integer like 276 and then performs
Dim CmdBuf() As Byte = New Byte() {Byte1, Byte2}
strHex = Hex(intNumber) which makes strHex equal to 114 in hex...
Next I need to break into separate bytes something like
Byte1 = Left(strHex, 1)
Byte2 = Right(strHex, 2)
But this does not work......Hex value of 114 needs to be converted into a couple of bytes like &H1 &H14 to be sent out the serial port.
.Write(Buf, 0, 2)
How can I do this?
View 4 Replies
May 8, 2011
I need to basically search for either a string such as "I-AM-RIGHT-OVER-HERE" or search for a sequence of bytes and return the offset of where that string or byte sequence is at.
View 1 Replies
Feb 26, 2009
I am using sockets and such for a while now, and want to go an step further in this. Now for example lets say an client would send [lenghtofstringinbytes]string[somethingelseinbytes]another thing.
How can I send/read/parse it?
Now I am doing this:
Private Sub onDataArrival(ByVal ar As IAsyncResult)
Try
Dim obj_SocketState As StateObject = CType(ar.AsyncState, StateObject)
Dim obj_Socket As Socket = obj_SocketState.WorkSocket
Dim sck_Data As String
[Code] .....
So using Getstring for it, but thats not the way for this as you get nothing else but an empty string back. So I have to parse it without converting it to an string.
View 10 Replies
Feb 19, 2011
I keep getting a ProtocolViolationException "Bytes to be written to the stream exceed the Content-Length bytes size specified." on the following code.I've tried setting Content-Length numerous ways with no success.
Dim url = "https://domain.com"
Dim req As WebRequest = WebRequest.Create(url)
req.Method = "POST"
req.ContentType = "application/xml"
[Code]...
View 1 Replies
Jun 17, 2010
I'm receiving a byte array from a network device by using the TcpClient class and as I have no idea how much data will be being sent I have to just declare a buffer that is X number of bytes long and keep reading into that until I've got all of the data. I then convert this byte array to a string using Text.Encoding.ASCII.GetString but the problem is that this gets any null bytes that were at the end of the buffer after the string and it includes them in the string. This then means when I do String.EndsWith it doesnt work as I would expect it to because there are just loads of 0 bytes at the end of the string.
Once I had realised that was what was happening (which took a long time as these null bytes are completely invisible when you are looking at the data in String form) I thought fine I'll just use Trim on the string but I've found that this doesnt make any difference at all. I thought Trim was supposed to remove any blank space from the start/end of a string, which I assumed would include empty bytes as well.
So is there any alternative I can use that will trim the empty bytes off the end or do I have to do it the 'manual' way and loop through my byte array before converting it to string and remove any null bytes? One thing that has just popped into my head as I'm typing this is to try using the Chr method and pass it 0 and combine that with Trim like so:
View 8 Replies
May 21, 2009
searching through memory at a given address range, and match a string of bytes specified i.e.
FindArrayOfBytes(Byval str as String, Byval range_start As Integer, Byval range_end as Integer) As Integer
The function should return the address start of where the array of bytes was found.
View 7 Replies
Sep 9, 2009
The application is working good, i can receive data on port 48888 and i can write it to my logfile, but my problem is when i convert bytes to string. I have the correct data, but all the bufferReadSize is filled with space. Example: if i send only: test, my log file will have test and 4 lines of space only. In my code, right after Dim clientdata As String = Encoding.ASCII.GetString(bytes).
I tried to trim(), replaceI() or any string manipulation, and it's not working!%!? Is there anything i need to do before i can start manipulating that string?
View 1 Replies
Aug 14, 2009
Can you mix vb and c# files in the same project for a class library? Is there some setting that makes it possible? I tried and none of the intellisense works quite right, although the background compiler seems to handle it well enough (aside from the fact that I, then, had 2 classes in the same namespace with the same name and it didn't complain). We're trying to convert from VB to C# but haven't finished converting all the code. I have some new code I need to write, but didn't really want to make a new project just for it
View 13 Replies
Sep 22, 2011
I created a text file contains 4 bytes of data
AABBCCDD
I just want to read the first 2 bytes (AABB) to execute it with my program.
Then I'll need to read the last 2 bytes (CCDD) for another computer routines
View 3 Replies
Jun 24, 2010
i wanta fileshare i think thats what it called prob not but his my code make it vb 2008 ||...these are two DIFFERENT EXE's
FILESHARE = "@JIOJDOSIAMDOSMAMPCA@"
public class shareReciever
Private sub btn1_click(blah)[code].....
View 3 Replies
Jul 23, 2010
I'm using the WndProc To get messages about USB flashdrives connecting and removing from the users computer. It works grand. I also use WMI queries to get the info about the flashdrives. It works as it shouold. The problem is when both of these are in the same solution. I ended up creating an extra .EXE that uses the WMI queries to get the drive info and output the info to a CSV file which my Main will parse. I tries creating a seperate class of each and i also tried to make a DLL that I import to no avail.
View 4 Replies
Mar 29, 2012
My app is basically console based but I need a Form to run in background. Adding a form in the app works but using Form1.Show didn't work, so I used VB.NET Application.Run(New Form1) However, in Form1_Load Me.Hide didn't work. I have no idea why. It works in buttons or other components in the same form.
View 1 Replies
Oct 9, 2010
First let me start off by saying that I have dealt with Winsock for MANY years and am attempting to convert my project over from vb6 to VB.Net.This program was made to handle up to 70 connections at a time and constantly sending data from Server to clients and back.
There is one packet however, that reaches up to be around 177kb when sent. The sockets are set up to sent 1kb at a time.... (No other packet actually uses the whole kb). It seems that after the server sends this large packet... the client receives the data out of order. After debugging and monitoring I find that it normally happens between 3-4kb. While the first 3 are good and in order.My question is, is there a different system I should use instead of just Sockets (I have had similar problems with TCPClient) and/or can someone maybe link me to a sample project that would not have this error?
View 1 Replies
Aug 2, 2009
Probably missing something silly here, Her eis what my display looks like Sending image...(401303) I would prefer it displays as Sending image...(391 kb)
[Code]...
View 7 Replies
Jun 30, 2011
Can someone who is using a 64 bit machine help me pintpoint this crash to either the VS2010 IDE itself or one of the plugins I have installed?
It's the code fragment below. When I copy & paste it into the Main() function of a new VB.Net console app on my Win7 64 bit machine, the VS IDE crashes and dies onthe spot, every time I try it.
Doing exactly the same on a 32 bit XP machine, nothing abnormal happens.
The 64 bit machine does have some IDE plug-ins installed, the biggest of which is DevExpress (the free version), so i think either one of those or the fact that the IDE is running on 64 bit must be the culprit.
This is the code. The static variable can also be made a module-level variable, with the same result.
View 2 Replies