I'm trying to send numbers over the serial port as bytes, not strings.
What I mean is if I want to send a 255, that should be 1 byte, not a 2
followed by a 5 and a 5. I'm trying to convert a borland c++ app.
This is what the c++ app does
int8B = 255;
WriteFile(serialPort,&int8B,1,&bytesWritten,NULL);
int8 = gainSlider->Position;
WriteFile(serialPort,&int8,1,&bytesWritten,NULL);
int8 = offsetSlider->Position;
WriteFile(serialPort,&int8,1,&bytesWritten,NULL);
int8 = exposureSlider->Position;
WriteFile(serialPort,&int8,1,&bytesWritten,NULL);
Here is what I'm doing that does not work
int x = 255;
sp.WriteLine(String.Format("{0}", x));
sp.WriteLine(String.Format("{0}", trackBar_Gain.Value));
sp.WriteLine(String.Format("{0}", trackBar_Offset.Value));
sp.WriteLine(String.Format("{0}", trackBar_Exposure.Value));
How do I send the 255? I can't do sp.WriteLine(255) since it wants a
string.
any help will be greatly appreciated.
Ringo 1 4348
"Ringo" <ri*********@gmail.comwrote in message
news:11**********************@a75g2000cwd.googlegr oups.com...
I'm trying to send numbers over the serial port as bytes, not strings.
What I mean is if I want to send a 255, that should be 1 byte, not a 2
followed by a 5 and a 5. I'm trying to convert a borland c++ app.
This is what the c++ app does
int8B = 255;
WriteFile(serialPort,&int8B,1,&bytesWritten,NULL);
int8 = gainSlider->Position;
WriteFile(serialPort,&int8,1,&bytesWritten,NULL);
int8 = offsetSlider->Position;
WriteFile(serialPort,&int8,1,&bytesWritten,NULL);
int8 = exposureSlider->Position;
WriteFile(serialPort,&int8,1,&bytesWritten,NULL);
Here is what I'm doing that does not work
int x = 255;
sp.WriteLine(String.Format("{0}", x));
sp.WriteLine(String.Format("{0}", trackBar_Gain.Value));
sp.WriteLine(String.Format("{0}", trackBar_Offset.Value));
sp.WriteLine(String.Format("{0}", trackBar_Exposure.Value));
How do I send the 255? I can't do sp.WriteLine(255) since it wants a
string.
any help will be greatly appreciated.
Isn't there a .Write method that accepts a byte array? That will avoid the
conversion to ASCII text.
Ringo This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Timothy Smith |
last post by:
hello people.
i've been trying to send an 8 byte string to my parallel port under
freebsd. the purpose is it to control a relay board.
the board simply responds to the output byte coming from...
|
by: ... |
last post by:
Hi
I need to send a chr(255) to a serial port. When I send it, through
comm.write (chr(255)) it sends a chr(63) ... in Hex, I write chr(&FF) and it
actually sends chr(&3F) ... why does this...
|
by: cvschie |
last post by:
Hi,
I have a LED Sign with standard software to control messages (via
serial port). Because the limitations of the software I want my own
VB.net program.
With a serial analyzer program, I see...
|
by: cmdolcet69 |
last post by:
How can i add a 5ms delay between bytes i send over to a controller?
I have to send 6 bytes in total however in between each byte i need to
have a 5ms delay.
|
by: Rich |
last post by:
Hello,
I am working on a python library for sending and receiving data from a Subaru's ECU (the fuel injection computer) via the OBD-II port and an OBD to USB cable, with the Subaru Select Monitor...
|
by: Gabriel Genellina |
last post by:
En Fri, 02 May 2008 16:50:46 -0300, Rich <richietommy@yahoo.comescribió:
No, chr works as it should. The same thing can be written as
ser.write("\x80\x10\xF0\x01\xBF\x40")
Are you sure you're...
|
by: Charles Crawford |
last post by:
Hi,
This apparently is a common problem and I've yet to read a solution that actually works for my specific situation.
I have a Zebra RW220 printer that I connect to via Bluetooth connection...
|
by: =?Utf-8?B?Q2hhcmxpZQ==?= |
last post by:
Hi,
This apparently is a common problem and I've yet to read a solution that
actually works for my specific situation.
I have a Zebra RW220 printer that I connect to via Bluetooth connection...
|
by: ajorge |
last post by:
Good Morning!
I'm trying to send a few bytes through my serial port into a remote system, but i'm having a problem... Suposing that i'm trying to send the array of bytes:
68, 00, 00, 68, 00,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
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,...
|
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,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
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...
|
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...
| |