473,326 Members | 2,090 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

How to send and receive 1024 Bits?

hello, I'm designing an interface using windows Forums and I want to send and receive 1024 bits using serial port, the number is in the hex-form, so what I did is the next:

Expand|Select|Wrap|Line Numbers
  1.   private void button2_Click(object sender, EventArgs e)
  2.             {
  3.                 int i;
  4.                 int a=0;
  5.                 byte[] mychar;
  6.                 mychar = new byte[128];
  7.                 string M = textBox1.Text;
  8.  
  9.                 for (i = 0; i < 127; i++ ) {
  10.                 mychar[i] = Convert.ToByte((M.Substring(a,2)),16);
  11.                 a += 2;
  12.                 }
  13.                 serialPort1.Write(mychar,0,127);
  14.             }
  15.  
and to check if the data is correct or not, I shorted out both the transmitter and receiver so I can see what I send from textbox1 to be shown in textbox5, the problem is the textbox is shown the output as ASCII, and I couldn't tell how to convert it to Hex again ,(see my attempt as commented bellow):

Expand|Select|Wrap|Line Numbers
  1. private void displaytext(object s, EventArgs e)
  2.         {
  3.  
  4.             textBox5.Clear();
  5.              textBox5.AppendText(RXstring);
  6. //int value = Convert.ToInt32(RXstring, 16);
  7.              //string stringValue = Char.ConvertFromUtf32(value);
  8.              //textBox4.AppendText(stringValue);
  9.         }
so to summarize my problems:
1- Is the code to send data is correct?
2- How can I force the textbox to show the output as Hex?

thank you very much.
Mar 31 '15 #1
0 1241

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: T.S.Negi | last post by:
Hi All, I have to write a stored procedure which will send/Receive text file from/to a server by using FTP. Is anybody have done anything on it? or know about it. If yes, I would like to know...
1
by: **** KiteOregon **** | last post by:
I need to send & receive XML Document Objects via the Message Queue. We have several applications that insert XML Document Object into the message queue. This works with no problem. I am trying...
1
by: Kitchen Bin | last post by:
Hi. I am trying to use Sockets to do multiple Send and Receives via HTTP (not simultaneously). A first pair of Send/Receives works fine and sure enough I receive HTML back, but the next...
1
by: EppO | last post by:
I wrote a small server/client app. I created a class for my customized socket object using (synchronous) Sockets functions for both server and client use. When client connects to server, if It...
4
by: saurabhaggarwal | last post by:
Hi Could anyone please tell me how can we capture send/receive event in MS Outlook. Suppose I want to pop up a message box when user hits send/receive button, how can we do that. Actually...
0
by: ChopDown | last post by:
Hi, I want to send/receive a serializable object in socket: ==========sender========== Dim MyMessage As New MessageClass.Message() Dim client As New TcpClient...
5
by: SungHyun Nam | last post by:
Hello, If there are two ethernet device, how I can select a device to send/receive? Actually I want to do loopback test between twe ethernet device. Send a UDP packet through eth0 and receives...
4
by: opkarmalkar | last post by:
I want to interface 8051 mcu to pc using USB port. I want to know that how can i send/receive a byte from pc to 8051 mcu via USB port using C language? is there any C program availaible which can...
1
by: eran otzar | last post by:
can any one point out the reason why u cant send and receive on a socket at the same time ? to my understanding there are 2 streams one to push and one to pull if you attempt to send/receive...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
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...
1
isladogs
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...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
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)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
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....
0
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...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.