473,394 Members | 1,866 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,394 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 1245

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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
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...
0
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 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.