Convert A Byte From The Rs232 Port To Unsigned Char Or Any Other Variable To Process It?

Mar 24, 2010

how can i, for example add a datum from the rs232 with other variable here is my code:

Dim ii As Byte
Dim c(100) As Char
c = Me.SerialPort1.ReadExisting()

[Code]....

View 19 Replies


ADVERTISEMENT

Convert Positive And Negative Math.Sin (waveform Output Values) Into (unsigned) Byte Array?

Apr 19, 2011

I'm creating an emulator for a device to simulate wave forms. My challenge is that when I try to convert the output of the following code, I can't convert the Math.Sin's double output into byte values that lend themselves to the byte array format required by an existing graphing control as listed at bottom below. I''m not sure how to handle this when the sin function creates negative values but the byte values will need to be positive and basically 'shifted up' so that anything over 127 is negative. (0 - 255) unsigned. BitConverter.GetBytes has been suggested but THIS is the result of that attempt.

[Code]....

View 2 Replies

Convert Char To Byte?

Jan 25, 2010

My application is reading in data from the serial port. The packet format uses 1 byte to tell the data length. The problem is as I am reading each byte in as a char when I try to get the value of the received character (using Asc(cRxd)) it only works up to values of 127, any bytes received that are over 127 are received as 63. I noticed that this was the default parity replace value, but I have parity.none set and I also changed the parity replace value. The received byte is always 63. I have tried reading the data using .ReadByte but this gives the same result - only works on values below 128.

View 1 Replies

VB In A Laptop Through USB Port And A USB-RS232 Converter To Communicate With A Microprocessor Using RS232 Protocol

Oct 18, 2010

I have developed a microprocessor based devise. It can communicate with laptop through RS232 as a VB application. Now most of laptops have USB port only. So I want to use USB replacing RS232 port on laptop side but not change anything on the device side. Can I do this using a USB-RS232 converter? How to change the VB software?

View 1 Replies

Converting Unsigned Byte To Signed Byte?

May 6, 2007

I would like to know how to convert a unisgned byte to signed byte

Atm I got this

a
Function readSignedByte() As SByte
'-128/127
Dim b As SByte

[Code]....

it doesn't work one that well works for numbers positive over 127 if lets say ReadByte() has 128 it would give overflow error which I don't want it to give I would like it to overflow the number to negivate value aka its signed value.

View 5 Replies

How To Handle 'unsigned Char *msg' Par

Sep 17, 2010

I am trying to write a VB.NET program that will call a function in an unmanaged C DLL passing the structure like this:[code]What I have not been able to figure out is how to handle the "unsigned char *msg" part. How would you define this in the VB.NET Structure?

View 2 Replies

Unmanaged DLL Structure Conversion (unsigned Char Pointer)

Oct 28, 2009

I'm making a "wrapper" for an unmanaged DLL (written, I'm fairly certain in C). I have a c++ "wrapper" that I'm trying to convert to VB.net. I've got most of the program working, but I've hit a brick wall.

I'm trying to convert the following two structures from their c++ versions to their vb.net versions. I cannot be sure which is the problem because both must be passed at the same time. The error I am getting is thrown by the object and indicates "Invalid structure size specified". I can cause this error on other objects when I either don't set the dwSize variable, leave off a parameter or change the parameter type incorrectly. Note that the dwSize parameter is supposed to contain the size of each structure. I'm successfully calculating that for my other structures and I'm using the same method on these and the results appear correct, so I do not believe the problem is found there. The object uses a lot of structures and the rest of them are working. These two are the only ones with a) an unsigned character pointer b) an unsigned long array and c) doubles.

C++ versions:

CODE:

I don't think I'm missing any parameters - the help file seems to agree with me on this, but it's theoretically possible that there is something missing (though I don't think so for other reasons as well). My suspicion is that it's dwPalette, pImageData or pMaskData with (in my uninformed opinion) more suspicion on the pImageData and pMaskData.

View 7 Replies

Convert A Byte Array From Socket Into A String To Replicate - How The Serial Port Receives Data

Sep 21, 2010

I've inherited a tested function that processes incoming data from a .NET Serial Port. (Dim RXBuffer as string = serialport1.ReadExisting) I've written a different part of the application that processes a byte array as received from an asynchronous .NET socket.

Is there a way I can convert the byte array into a string as if it arrived from the serial port?

I would prefer to rewrite a very long 'if statement' into byte array functions syntax that look like:

dim b as boolean = IsBitSet(state_buffer(i), j) 'rather than:

dim b as boolean = (Asc(Mid(RXPacket.Pdu, CInt((i - (i Mod 8)) / 8) + 1, 1)) And CInt(2 ^ (i Mod 8))) > 0

View 3 Replies

C# - How To Properly Read 16 Byte Unsigned Integer With BinaryReader

Jun 9, 2010

I need to parse a binary stream in .NET to convert a 16 byte unsigned integer. I would like to use the BinaryReader.ReadUIntXX() functions but there isn't a BinaryReader.ReadUInt128() function available. I assume I will have to roll my own function using the ReadByte function and build an array but I don't know if this is the most efficient method?

View 3 Replies

Reading Signed And Unsigned Values From A Stream In Both Byte Orders?

May 23, 2011

I need to read signed and unsigned 8 bit, 16 bit and 32 bit values from a file stream which may be little-endian or big-endian (it happens to be a tiff file which carries the byte order indicator at the start).I initially started by writing my own functions to read the values and was able to do so for unsigned values. e.g.

Public Function ReadUInt32() As UInt32
Dim b(4) As Byte
input.Read(b, 0, 4)

[code]....

But then I started looking at signed values and my brain broke.As an alternative, I found the IO.BinaryReader which will let me read signed values directly but doesn't seem to have any way to indicate that the data is big-endian or little-endian.Is there a nice way of handling this? Failing that, can someone tell me how to convert multiple bytes into signed values (in both byte orders)?

View 2 Replies

Hooking The Comm Port (RS232)?

Nov 2, 2011

I currently have software that sends out plain text(i.e. 'X') to comm 1 port and was wondering if there was any way to capture that plain text and also respond to that port on the same compute as the port without having anything plugged into the machine (i.e. 9 pin serial cable). I am trying to avoid buy any more hardware as this is an objective to acutally cut down on hardware.

View 1 Replies

VS 2005 How To Read From RS232 Port

May 2, 2011

I have been using VB 6.0 and new to VB.net (VB 2005) I want to know how to read characters from RS-232 port.

I have created serialport object and want to read this sort of thing "A,2451.3955,06715.8253"

View 8 Replies

IDE :: Serial Port Communation Using Usb To Rs232. In Collage

Mar 18, 2011

i have some code here that is used for a project, the code is used in visual basic 6 and i am using visual studio 2008 in the project i have to communicate with a PIC micro controller, i do not know what to do because in visual basic 6 w use MS comms and in visual studio 2008 uses a serial port thing code below.[code]

View 3 Replies

Read / Write Data From RS232 Port?

Aug 23, 2010

I need to write and read data from a RS232 port. On the RS232 port there is a RFID Card reader-Writer connected. So I need to send hex codes to the device, and have to poll every 1sec if there is a card in the system. If there is a card I need to read the info that is on the card. My biggest problem is I think is that I am not sure how many characters there will be in return after the read command (maybe it is always the same length this I am not sure). What is the right way to read-write to the com port. So I always got the same result and not skipping a code.

View 12 Replies

Read Incoming Data From RS232 Port?

Sep 28, 2011

I want to create an application in VB.net that will read data outputted by a RFID reader on serial port.I want to know how will my application be able to identify the interrupt generated by Serial port and will read data from there?

View 2 Replies

Read All Data From Serial Port (Com1 / RS232)

Nov 2, 2009

I am trying to make a program in vb 2005 to real all the data from a device connected on Serial Port (Com 1).i did this: [code]and this is how i want to reciveit.when i lounch the program i only receive first line "410001+00000001" and after that i get on the device rs232 error.

View 6 Replies

Rs232 Serial Programming - Port To C# - .net Code Works Correctly - C# NOT?

Nov 5, 2009

The vb.net code is functioning correctly as it talks to a device through COM1 serial port.What I was hoping was the equivalent c# code is not creating the same string and as a result, the serial 'packet' is not correct. Check this illustration of my problem [URL]...

My goal is to eliminate the addition of the extra characters '/0' and '/b' that what I hoped was the c# equivalent to the correctly functioning vb.net code. It just occurred to me I should change the code to employ Stringbuilder. The 'packetbuilder' method/function builds a string and keeps concatenating things to itself.

[Code]...

View 5 Replies

Change Byte() To Structs For Readability And Convert Struct To Byte Stream For Socket Send()

Dec 8, 2009

I just converted the following code from c# to vb.net. It is functional and works correctly with my company's firmware/devices. My next challenge. Previous serialport code used much more readable structs which where then converted (after building a packet) into byte() automatically as part of the serialport encoding. (this is my understanding)How could I

1. morph byte arrays 'ToSocket' and 'ToMTP' below into structs and

2. convert into byte array for Socket.BeginSend(byte(),.....) to stream out to remote devices?


Imports System.ComponentModel
Imports System.Text
Imports System.Net.Sockets

[Code]....

View 3 Replies

Convert A IntPrt To Byte Array (Byte())?

Nov 18, 2010

How could you convert a IntPrt to a Byte Array (Byte()) ?

View 19 Replies

Convert Byte Array Into A String Like So Dim Byt As Byte()?

Jan 25, 2011

I have a byte array that I convert into a string like so Dim byt As Byte() = New Byte(255) {} s = New String(Encoding.ASCII.GetChars(byte))My question is when I look at the string in a debuger its clearly a normal string but when I compare it to what I know its supposed to be it doesnt equal. So i did a quick check and for some reason its return a string thats the length of 256 characters. So i did a s.trim and it still is 256 characters long.

View 1 Replies

Re-encoding Char - Perform The Recast While Converting To A Byte So It Will Fit And Not Buffer Overrun?

Sep 28, 2010

I can't seem to find how to recast a char to Ascii, the VB6 way was to ASC(thechar/thestring).What is the new method? or how to perform the recast while converting to a byte so it will fit and not buffer overrun.

View 10 Replies

VS 2008 - Getting Signal From PIC16F877A To VB 2008 Through Rs232 Serial Port

Mar 5, 2010

What i need to write is i get different signal from PIC16F877A and through serial port, i need to display diffrent text from different signal, Such as: Signal from portB.1 display 1, signal from portb.2 display 2. Between the microcontroller and serial port im using MAX232.

View 2 Replies

Convert ASCII To Char?

Feb 15, 2009

I have a string of ASCII in HEX. ( 5A65726f)so first i split them into 2s >>>> 5A 65 72 6f then i change the hex to integer using these integer i convert them to char using chr() it did the job great, i can see the correct word i want..but it give me an error saying " make sure it has the right format" ( error shown below)

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Dim hexnum As String
Dim converttohex As String
Dim hextonum As Integer

[code]....

i thought it was the for loop problem...since i will go up to 7 while len(hexnum) is 8 so it would loop again but there is nothing after 8th HEX?so i tried For i = 1 To Len(hexnum)-1 Step 2 ...this time...textbox didnt show anything...+ the same error came up...

View 4 Replies

Convert Char To Binary?

May 1, 2012

I want to make a program that can make:

1.) check if a character is in a text file

2.) if the character exist then convert the character into binary code

3.) display the result in a textbox.

Here is my code:

' s is my txt.file
' in this code i want to check if char "g" is the in the txt.file
If InStr(1, s, "g") > 0 Then

[Code].....

View 4 Replies

Convert Datetime To Char?

Apr 23, 2009

I get this result for "select GETDATE()"

2009-04-22 23:09:02.590

What is the best way to convert the datetime to only char like below?

20090422230902590

View 2 Replies

Convert String To Char?

Jun 5, 2011

I am writing a database and need to post a value in a lable to a sql field.the sql datatype is set to money.when posting i have

CMD.Parameters.addwithValue("@Claim", LBCLAIM.text)

when posting i gett an error

cannot convert a char vaule to money. the char vaule has incorrect syntax.

View 1 Replies

How To Convert String To Char

May 27, 2012

I want to convert say Input: textbox1.text=blabla Output: blabla becomes into: textbox2.text=(char45 & char34 char45 & char34 char45 & char64 )

[code]...

View 1 Replies

Write A Signed Byte To A Serial Port

May 3, 2012

I need to be able to write signed bytes to a serial port using SerialPort.Write() method, except that method only takes byte[] arrays of unsigned bytes, how would i write a signed byte to the serial port?For what I'm working on the particular command takes values from -1700 to 1700.

View 1 Replies

VS 2008 : Converting A "binary String" Into A Byte Or Char?

May 23, 2010

I've been trying to figure this out for hours now, and I've given up on trying to solve it myself. Basically what I need to do, is convert a "double octet" binary string, such as "11010011 01011101", into a byte or char type if possible.I use the following code to convert my Unicode text into binary:

Private Function ByteToStr(ByVal bt() As Byte) As String
Dim st As New StringBuilder
For Each byt As Byte In bt

[code]....

But that gives me weird results. The "Convert.FromBase64String" obviously isn't what I'm after. Any help would be great. If I can convert the "binary string" into a bytes or chars I can get it into a string.

View 6 Replies

Comparison Error Operator "=" Is Not Defined For Types 'Byte' And 'Char' While Converting C#

Jan 21, 2011

I am in the process of converting some c# code to that of VB.NET...I am running into error at the following

[Code]...

View 2 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved