16,009,847 members
Sign in
Sign in
Email
Password
Forgot your password?
Sign in with
home
articles
Browse Topics
>
Latest Articles
Top Articles
Posting/Update Guidelines
Article Help Forum
Submit an article or tip
Import GitHub Project
Import your Blog
quick answers
Q&A
Ask a Question
View Unanswered Questions
View All Questions
View C# questions
View C++ questions
View Javascript questions
View Visual Basic questions
View .NET questions
discussions
forums
CodeProject.AI Server
All Message Boards...
Application Lifecycle
>
Running a Business
Sales / Marketing
Collaboration / Beta Testing
Work Issues
Design and Architecture
Artificial Intelligence
ASP.NET
JavaScript
Internet of Things
C / C++ / MFC
>
ATL / WTL / STL
Managed C++/CLI
C#
Free Tools
Objective-C and Swift
Database
Hardware & Devices
>
System Admin
Hosting and Servers
Java
Linux Programming
Python
.NET (Core and Framework)
Android
iOS
Mobile
WPF
Visual Basic
Web Development
Site Bugs / Suggestions
Spam and Abuse Watch
features
features
Competitions
News
The Insider Newsletter
The Daily Build Newsletter
Newsletter archive
Surveys
CodeProject Stuff
community
lounge
Who's Who
Most Valuable Professionals
The Lounge
The CodeProject Blog
Where I Am: Member Photos
The Insider News
The Weird & The Wonderful
help
?
What is 'CodeProject'?
General FAQ
Ask a Question
Bugs and Suggestions
Article Help Forum
About Us
Search within:
Articles
Quick Answers
Messages
Comments by Member 11423970 (Top 46 by date)
Member 11423970
16-Jun-15 4:18am
View
Very helpfull. Thanks.
Member 11423970
2-Jun-15 14:59pm
View
Ok, thanks for everything anyway.
Yes, I already accepted your answer formally... didn't I?
Member 11423970
2-Jun-15 5:19am
View
I tried using this piece of code but I don't know how can I call the class and send and recieve data from it.
Member 11423970
1-Jun-15 7:41am
View
Hi Sergey.
I managed to do what I needed for my Project, I upgrade the code shown above.
Nevertheless, I think is not what you were suggesting me, so if you can upload an example that would be great.
I'm also trying to show in one of the tabpages an specific image depending of input data, but even if in my computer works correctly, when I tried it on my portable device the image does not show.
Member 11423970
29-May-15 3:55am
View
Hello again.
I added my code. I have created tabpages using the information you provided me, but I an unable to add an image to the tabpage using Onpaint method or any other method.
Member 11423970
28-May-15 15:29pm
View
I know how to use System.Drawing.Graphics to draw an image in the main form, but I don't know how to do it in a tabpage. I don't know the the code line to refer to that specific object. Can you put me an example or a link to a page that talks about that?
Member 11423970
28-May-15 13:39pm
View
Thanks for replyng. I'm quite new with programming so forgive my lack of vocabulary.
I have created two typepages in the main form using the designer ("System.Windows.Forms.TabPage1" and "System.Windows.Forms.TabPage2") and I want to change de background image of both of then. I searched throw the net how to add a background image to the main form, and I guess that to do the same with the tabpages I have to use the Onpaint method, but I don't know how and I find nothing in the net.
Member 11423970
24-Mar-15 6:05am
View
No, there are no timers.
I more or less solve the problem closing the serial port after doing the first taks and opening it again to continue with the readTo task. Is not probably the best solution but is quite straightforward.
If you can think in other explanation or solution, it would be more than welcome.
Thank you very much for replying anyway.
Member 11423970
24-Mar-15 4:52am
View
Yes, I tried with all the Reading methods, but it gets stack in that line. I had some problems programing in datareceived thread, thats why I finally did it this way.
What is funny is that when I don't use the Botonclick method, it Works perfectly, but if I used it to give priority to another task, it Works great until the 'readTo' line.
Member 11423970
6-Mar-15 2:52am
View
Sorry guys. I wasn't available. So you are telling me to implement you solutions where exatcly? I tried them in my main form and in my main form designer and still not working, so I'm probably doing something wrong with your solutions.
Member 11423970
16-Feb-15 11:00am
View
Ok, thak you very much for all the help
Member 11423970
16-Feb-15 10:22am
View
Very complete answer and very helpful resources. I have read them and I will work with them. I general, you are suggesting me to créate an Async Method?
Member 11423970
16-Feb-15 9:03am
View
Yes, I'm a beginner with programming, so forget me if I don't get all of your answer. No loops to wait, got it. The input_data ends with an special character that doesnt' appear on this screen, so the idea is taht, read all the input data and when the symbol appears says, this is all my string of information, and send the next code to recieved another piece of data.
Member 11423970
16-Feb-15 8:42am
View
I don't know if there is any command that allows me to wait until the serial port sends all the data before sending the second code.
Member 11423970
11-Feb-15 4:31am
View
That's it!!! Thank you very much for your help, it Works perfectly. Thanks!
Member 11423970
11-Feb-15 3:45am
View
I upload the new code. I change char array for a byte array but I still have a different answer.
Member 11423970
11-Feb-15 3:04am
View
Then I don't know what I'm doing wrong with my verification program. I wrote this main program, and my result is not the same:
Member 11423970
10-Feb-15 10:53am
View
Sorry again for bothering. I translate the code to C#, but aparently is wrong in some point, because the result is 0x913C instead of 0x313C. I cannot manage to see where is the error.
Member 11423970
10-Feb-15 8:24am
View
Deleted
Ok, thanks. I will try to convert the code to C#.
Member 11423970
10-Feb-15 8:00am
View
Better said, I didn't find it, is the one of the webpage you suggested me. I've been analysing it and I think that mine does the same, but I am not sure.
Member 11423970
10-Feb-15 7:58am
View
I've found this other algorythm of Xmodem, but I am not sure if is the same as mine as is writen in C. Maybe I am missing something.
int calcrc(ptr, count)
char *ptr;
int count;
{
int crc, i;
crc = 0;
while (--count >= 0) {
crc = crc ^ (int)*ptr++ << 8;
for (i = 0; i < 8; ++i)
if (crc & 0x8000)
crc = crc << 1 ^ 0x1021;
else
crc = crc << 1;
}
return (crc & 0xFFFF);
}
Member 11423970
10-Feb-15 7:55am
View
I checked both, but nothing that can solve my problema appears :(
Member 11423970
10-Feb-15 6:04am
View
I am almost sure that the problema is in the algorythm. I initialise the values to 0x0000 and 1021 which are the ones used for Xmodem CITT but there must be something with the bit order I am using.
I read in this webpage some reversing process but I don't understand it very well: http://tiku.io/questions/599184/crc16-checksum-hcs08-vs-kermit-vs-xmodem
Member 11423970
10-Feb-15 5:03am
View
I tried using the polynom, but I still have an incorrect CRC. I read the C code example and I think that the algorythm is ok, so I don't know where is the problem. I feel that this is getting very close, but I'm not able to find why I can calculate the CRC-16 and CRC Kermit numbers and not the Crc-Citt Xmodem number.
It should be simple to generate the Xmodem number but I don't know why is becoming so hard.
Member 11423970
9-Feb-15 12:54pm
View
Ok, I'll try that then.
Thank you very much.
Member 11423970
9-Feb-15 12:51pm
View
Deleted
I input for example "123456789" like in the web page, and with a Kermit type inicialization or a CRC-16 initialization, I obtain the same reults as in the web page, but when I try a Xmodem initialization of the crc values, I obtain a completly different result.
Member 11423970
9-Feb-15 12:37pm
View
I think I don't understand it correctly. I am writing a program where I write a number and it calculates the CRC Xmodem number of 4 caracters. I don't need to send it anywhere or recieved acknowledment. The programe I am trying to write is similar to the one on this page: http://www.lammertbies.nl/comm/info/crc-calculation.html
Member 11423970
9-Feb-15 12:21pm
View
I am using a Byte array of 4096 bytes, is not that suppossed to be enough?
Member 11423970
9-Feb-15 11:58am
View
I am very sorry, I have spent so many hours with this program that already I don't know what I am uploading.
And believe me that I am not just "copying" code. I read all the answers, the good ones and your conplains, but most of the time you people just send me to other web pages, in where I read the same information again and again, and even if I a read it carefully, I can get to finished the program.
I'm sure that for you is a silly program, and that you can't came up with the problem right away, but for me is quite hard. Probably you think that I am a noob and all the things that you usually say to people you think inferior to you and that I should be doing a different thing in order to programming.
I check a lot of algorythms to take out the CRC number, most of them say different thing, or that is my perception, and I tried a lot of them, I wrote a lot of them myself taking into account other programmers ideas and comments and none of them worked.
Mr. OriginalGriff, you can be tired of me and remove my questions, but do not insult me saying that I am doing nothing and that I am taking advantage of your work and the one of the rest of the programmers.
Member 11423970
9-Feb-15 11:40am
View
You mean that I need to change just the algorythm part or that the whole program needs to be changed?
Member 11423970
9-Feb-15 4:01am
View
After checking both pages, I still don't get where is the problem.
Member 11423970
6-Feb-15 3:17am
View
http://www.lammertbies.nl/comm/info/crc-calculation.html
Member 11423970
5-Feb-15 4:32am
View
Deleted
for (int i=0;i
Member 11423970
5-Feb-15 4:31am
View
Deleted
my code now looks like:
class Program
{
public static ushort[] crc_table =
{
0x0000, 0x1021, 0x2042, 0x3063, 0x4084, 0x50a5, 0x60c6, 0x70e7,
0x8108, 0x9129, 0xa14a, 0xb16b, 0xc18c, 0xd1ad, 0xe1ce, 0xf1ef
};
public static ushort CalculateCrc( byte[] data )
{
int i;
ushort crc = 0;
int len = data.Length;
unchecked{
for (int j = 0; j < len; j++)
{
i = ( crc >> 12 ) ^ ( data[j] >> 4 );
crc = (ushort) (crc_table[ i & 0x0F ] ^ ( crc << 4 ));
i = ( crc >> 12 ) ^ ( data[j] >> 0 );
crc = (ushort) (crc_table[ i & 0x0F ] ^ ( crc << 4 ));
}}
return crc;
}
public static void Main(string[] args)
{
string a = "123456789";
byte [] number = new byte[32];
for (int i=0;i
Member 11423970
5-Feb-15 4:30am
View
I hava tried both, to mask and to unchecked. With both I avoid now the overflow, but the result I get it isn't the same as the one in http://www.lammertbies.nl/comm/info/crc-calculation.html web page.
Member 11423970
4-Feb-15 4:36am
View
Ok, thanks a million for the answer and the lesson.
Member 11423970
4-Feb-15 4:13am
View
As I am using them as a public enum I declared them as int, but still not working
Member 11423970
4-Feb-15 4:12am
View
I tried that before, Crc16Ccitt CRC = new Crc16Ccitt(InitialCrcValue.Zeros); , which is the one I am actually looking for, but the builder tells me that InitialCrcValue and Zeros do not exist, and I do not know which declaration type are.
Member 11423970
4-Feb-15 4:01am
View
In my main program I am defining the Class and trying to use it, but I do not know whats wrong in the definition of the class.
Crc16Ccitt CRC = new Crc16Ccitt();
string myCRC = CRC.ComputeChecksumBytes(number).ToString();
Member 11423970
4-Feb-15 3:46am
View
Here is my main program. I just need to try the CRC class that I found and créate a CRC Xmodem calculator to use it in a project
Member 11423970
4-Feb-15 3:36am
View
Deleted
for (int i=0;i
Member 11423970
4-Feb-15 3:33am
View
Deleted
This is my main program. I take a string, change it to an byte array and define the class to where I want to send the data.
class Program
{
public static void Main(string[] args)
{
Console.Write("Write the number: ");
string a = Console.ReadLine();
byte [] number = new byte[16];
for (int i=0;i
Member 11423970
4-Feb-15 3:14am
View
I need to write a main program in where I can write a number, and the class shown above returns me the CRC XModem of that number.
Member 11423970
4-Feb-15 2:33am
View
I don't get it very well. I know it is something to do with ushort, but I don't know how to do the masking.
Member 11423970
4-Feb-15 2:30am
View
Happens the same. I just create an array of 256 because at the beggining was of 16, and I thought that was the cause of the overflow, but after changing, the problem persisted.
Member 11423970
3-Feb-15 14:37pm
View
Yes, I debugged it. The problem is in the 'for'. When it starts the second loop, it overflows:
for (int j = 0; j < len; j++)
{
i = ( crc >> 12 ) ^ ( data[j] >> 4 );
crc = (ushort) (crc_table[ i & 0x0F ] ^ ( crc << 4 ));
i = ( crc >> 12 ) ^ ( data[j] >> 0 );
crc = (ushort) (crc_table[ i & 0x0F ] ^ ( crc << 4 ));
}
Show More