Does the following code result in the hex value "05" being written to the serial port? - int test21 = 0x05;
-
byte[] test = new byte[1];
-
test[0] = (byte)test21;
-
dexConnection.Write(test, 0, test.Length);
6 1225
Probably. Why cast it as an int first, why not start with a byte?
Probably. Why cast it as an int first, why not start with a byte?
I just find it easier to see clearly the hex value I am using to put it into an int variable like that. I think I may actually have some sort of problem with how it is being written to the serial port. When I hook up my pc running the application using the code I posted to write to the serial port, Hyperterminal on the other end show that it is receiving the character "P", and according to my ascii chart 05 in hex is equal to the ENQ character. Is "P" what I should be seeing on hyperterminal while using my code to write hex "05"?
There is nothing invalid about doing this: -
byte test21 = 0x05;
-
byte[] test = new byte[1];
-
test[0] = test21;
-
dexConnection.Write(test, 0, test.Length);
-
If you are not getting the characters you think that you should, you might not be talking at the same baud rate?
There is nothing invalid about doing this: -
byte test21 = 0x05;
-
byte[] test = new byte[1];
-
test[0] = test21;
-
dexConnection.Write(test, 0, test.Length);
-
If you are not getting the characters you think that you should, you might not be talking at the same baud rate?
Both PC's are running at a baud rate of 9600.
Both PC's are running at a baud rate of 9600.
Hmm, I dunno then. But I certainly would recomend not using int's cast to bytes if you can help it.
Unlike 0x01-0x04, 0x05 does not seem to be a printable character in hypreterminal (you can test with CTRL+E...or CTRL+A -> CTRL+D)
Hmm, I dunno then. But I certainly would recomend not using int's cast to bytes if you can help it.
Unlike 0x01-0x04, 0x05 does not seem to be a printable character in hypreterminal (you can test with CTRL+E...or CTRL+A -> CTRL+D)
My problem turned out to be a bad cable connecting to one of the devices I was trying to communicate with, resoldering of the cable fixed my problems.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: willie |
last post by:
Hi,
I'm writing a program which requires the use of three serial ports and
one parallel port. My application has a scanning devices on each port,
which I can access fine with pyserial. ...
|
by: joe bloggs |
last post by:
I am writing a mobile application to interface with a legacy system and I am
planning to use web services to communicate with this system. The legacy
system receives data through a serial port. ...
|
by: Frank |
last post by:
Hello,
how to get information about all serial ports in the PC?
I use the following code, but i got only the data of the FIRST serial port.
All other serial port information are not available...
|
by: Rob |
last post by:
Hi all,
I am fairly new to python, but not programming and embedded. I am
having an issue which I believe is related to the hardware, triggered
by the software read I am doing in pySerial. I...
|
by: terry |
last post by:
Hi,
I am trying to send a character to '/dev/ttyS0' and expect the same
character and upon receipt I want to send another character. I tired
with Pyserial but in vain.
Test Set up:
1. Send...
|
by: DolphinDB |
last post by:
Tired of spending countless mintues downsampling your data? Look no further!
In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
|
by: ryjfgjl |
last post by:
ExcelToDatabase: batch import excel into database automatically...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: Vimpel783 |
last post by:
Hello!
Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
|
by: jfyes |
last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
|
by: PapaRatzi |
last post by:
Hello,
I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
|
by: Defcon1945 |
last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
|
by: Shællîpôpï 09 |
last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
| |