|
Let me get this straight, because I think there are language barriers here. In reference to your example data... a 'BLOCK' is considered everything between 0x55 and 0xCC right? If this is the case, then a couple of your example data sets have multiple blocks. Luc is right in his previous post that data has to escape the fencepost identifiers if they appear inside the payload. And the issue is that your dividing into BLOCKS is not working as expected? No exceptions, just not valid results, ya?
"Simplicity carried to the extreme becomes elegance."
-Jon Franklin
|
|
|
|
|
1) The first 'for' loop does not use its indexer. You can easily change the 'for' loop to a 'foreach' loop and iterate through the bytes. This will simplify your code a little.
2) Do comparisons of bytes, don't convert to strings.
3) If you're working in hex numbers use hex numbers throughout your code, don't mix up number bases. This will make your code easier to understand.
4) Your logical comparisons should use the logical && operator and not the & operator. The & operator returns a bitwise operation resulting in a number, not true or false. They are VERY different.
5) You should always put magic numbers in your code as constants.
public const Byte StartDelimiter = 0x55;
You should never sprinkle those into code manually, you run a huge risk if you are forced to refactor your work. Not to mention that you may mistype one.
6) I would avoid doing tricks with your loop variable like incrementing/decrementing it inside your loop block unless it is absolutely necessary - which should be never.
7) Match your braces. Just because you don't necessarily have to put them in after an 'if' statement doesn't mean you shouldn't. IMHO.
8) Do yourself a favor and look up the State Machine design pattern, it works very well for these kinds of problems.
9) When I ran your program (with healthy fixups) I found that you presumed that every 0xCC,0xCC was an end delimiter. This, apparently, is a false presumption. CCCC appears in your third dataset as valid information, and should not be treated as a fencepost delimiter. fix that up and I think you should get valid results, or at least get you further along.
Regards,
"Simplicity carried to the extreme becomes elegance."
-Jon Franklin
|
|
|
|
|
This is one of the best, and most thorough answers I have ever read, and I agree with every bit of it. I even learned a bit. Thanks!
Will Rogers never met me.
|
|
|
|
|
Hi ,
Is there a way to change the table name of a datatable in a dataset or create a new dataset and copy the table with a new name in to the new dataset?
Jack Sparrow
--------------------------------------
Defeat is not the worst of failures. Not to have tried is the true failure.
|
|
|
|
|
Use below code and next time try to use Google
dataset.Tables[0].TableName = "MyTable1";
dataset.Tables[1].TableName = "MyTable2";
or do it in loop
for (int i = 0; i <= dataset.Tables.Count; i++)
{
dataset.Tables[i].TableName = "MyTable" + i.ToString();
}
|
|
|
|
|
Thanks mate, really not sure how I missed this...
Jack Sparrow
--------------------------------------
Defeat is not the worst of failures. Not to have tried is the true failure.
|
|
|
|
|
you are welcome
|
|
|
|
|
Here is the error:
System.Data.SqlClient.SqlException: Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding.
I receive this after ~32 seconds of running a SqlCommand. Now, normally the default timeout is 30 seconds, but I have increased this up to 10 minutes and still the timeout happens in 30 seconds. The connection string says Timeout=600 and I do not override this anywhere in the code. In fact, I can print the timeout prior to running the query and it says 600.
Am I missing something obvious here?
|
|
|
|
|
There are two different time outs for SQLConnection and SQLCommand.
Set longer timeout to the SqlCommand object (30 is default).
I hope if this helps
|
|
|
|
|
Also,
While declaring the command object set the timeout property 0 i.e. infinity.
SqlCommand cmd = new SqlCommand();
cmd.CommandTimeout=0;
Try this!
|
|
|
|
|
Very clever that you reply twice so I can give you two 5's
Answer is very much appreciated (with small modification)!
SqlCommand cmd = new SqlCommand();
cmd.CommandTimeout=con.ConnectionTimeout;
Now I can still modify the timeout just from the config file's connection string.
|
|
|
|
|
yes, dats better to keep config in scene!
i was in hurry to head towards home, so just didnt modify and took a new message post instead
|
|
|
|
|
You're setting the timeout on the CONNECTION attempt, not the query execution timeout. You do that in the SqlCommand object you're using to execute your query.
|
|
|
|
|
We have an ASP.NET 3.5 site that uses themes and skins for handling css and images. Now we are about to create a new site that should have a common look and feel and I like to share the App_Themes between the sites so that they always will have the same look.
Anyone that have any experience in this topic?
_____________________________
...and justice for all
|
|
|
|
|
Answer is Global Themes
A global theme is a theme that you can apply to all websites on a server. They are much alike to Page themes except that their scope is set at server level.
we need to add <pages> element with Theme attribute in Machine.config file which defines global theme for whole server.
*- Google for more information and implementation.
|
|
|
|
|
Interesting! Do you have practical experience in how this is set up with projects in Visual Studio. Most developers should not have to bother about styles and images but need to be able to run the whole site locally.
_____________________________
...and justice for all
|
|
|
|
|
This is C# Forum so I Recommend you to move your question to ASP.net Forum for better response.
modified on Wednesday, December 29, 2010 10:46 PM
|
|
|
|
|
Can I restrict or block access to a specific registry key in HKLM?
Or maybe hook it so that another process cannot read it?
My goal is to temporarily block/obscure access to an HKLM registry key by the winlogon process, remotely.
Thanks!
|
|
|
|
|
|
Sounds like somebody is trying to hack some software , but you can set permissions on registry keys.
|
|
|
|
|
The only way to do that would be to setup permissions on that key preventing the user from reading it.
You can NOT prevent WinLogon from reading it's values. Why? Because even Windows has to login to itself! Various accounts, including Local System and service accounts, need access to WinLogon to execute.
I cannot think of a single reason why you would want to do this.
|
|
|
|
|
I will give you a single reason
I want to write a remote desktop application with the ability to stop the legal banner from popping up therefore not requiring user action before the login/password/domain are sent, because that hoses the entire process since that window handle cannot be identified (because the contents are encrypted) I cannot close that legal banner pop up window ... however if I can stop it from opening then the result is the same.
|
|
|
|
|
You might want to check with your legal department first. You might not get away with circumventing that little screen, as annoying as it is.
|
|
|
|
|
If I can figure out how to do it, I will then ask ... no point in asking ahead of time if I can't do it.
Any idea how to do the block?
|
|
|
|
|
That's ass end backwards. Is there any reason to waste time researching how to do this if your legal department tells you that you can't do it? You're just costing your company money here.
|
|
|
|