|
Hi,
there is one positive aspect on your last message: it tells us how the LRC is calculated, as an EXOR, biased by 0xAA. That seems reasonable. This info being copy-pasted keeps me suspicious though. I'd rather see a real document, or see a single command (ANY command) getting accepted...
there are many negative aspects: it is not really a specification, there hardly is any text; it is just two examples, the second even incomplete (no LRC value).
And then there is a major problem (which I already mentioned earlier): the version example cannot possibly be correct, I can't explain its length (NUM field) AND now its checksum also seems incorrect.
I wrote a program that takes such a string, converts it to all bytes, then checks length and checksum. I tried with the string given in the example, and with a number of variations thereof (amending the response trying to get a matching length and a matching LRC), and nothing matches. Here is what I obtained:
versionResponse (from example)
input = %R 0x0C 0x01 UHD-4K 02.10.09 0xC2
bytes = 25 52 0C 01 55 48 44 2D 34 4B 30 32 2E 31 30 2E 30 39 C2
Found error(s):
Bad NUM; got 12 while expecting 16
Bad LRC; got C2 while expecting D1
--------------------------------------------------------------------------------
versionResponse, length fixed
input = %R 0x10 0x01 UHD-4K 02.10.09 0xC2
bytes = 25 52 10 01 55 48 44 2D 34 4B 30 32 2E 31 30 2E 30 39 C2
Found error(s):
Bad LRC; got C2 while expecting CD
--------------------------------------------------------------------------------
versionResponse, length fixed+space added
input = %R 0x11 0x01 UHD-4K # 02.10.09 0xC2
bytes = 25 52 11 01 55 48 44 2D 34 4B 20 30 32 2E 31 30 2E 30 39 C2
Found error(s):
Bad LRC; got C2 while expecting EC
--------------------------------------------------------------------------------
versionResponse, hex in version numbers
input = %R 0x0C 0x01 UHD-4K 0x02.0x10.0x09 0xC2
bytes = 25 52 0C 01 55 48 44 2D 34 4B 02 2E 10 2E 09 C2
Found error(s):
Bad NUM; got 12 while expecting 13
Bad LRC; got C2 while expecting C0
--------------------------------------------------------------------------------
versionResponse, hex in version numbers, space added
input = %R 0x0C 0x01 UHD-4K # 0x02.0x10.0x09 0xC2
bytes = 25 52 0C 01 55 48 44 2D 34 4B 20 02 2E 10 2E 09 C2
Found error(s):
Bad NUM; got 12 while expecting 14
Bad LRC; got C2 while expecting E0
--------------------------------------------------------------------------------
versionResponse, hex in version numbers, periods removed
input = %R 0x0C 0x01 UHD-4K # 0x02 0x10 0x09 0xC2
bytes = 25 52 0C 01 55 48 44 2D 34 4B 20 02 10 09 C2
Found error(s):
Bad LRC; got C2 while expecting E0
NB: I am ignoring all spaces in the input string as they were present around hex bytes; however I defined the # sign to represent an actual space, so I was able to force one in the version string, but that did not help.
It is up to you now, the limited information you provided is inconsistent; there is nothing more I can do.
PS: about your statement "I receive what I transmit" (if I understood you correctly). Maybe the device echoes all commands it refuses because they are invalid, e.g. because the checksum still is not what you think it should be. There is a way to make sure: create a program that sends a command with checksum value X=0, wait 1 second, read the result; increment X and repeat until you don't get an echo. If and when that happens, you might have the correct checksum (maybe it is as simple as bias isn't 0xAA but some other constant).
Luc Pattyn [My Articles]
The Windows 11 "taskbar" is disgusting. It should be at the left of the screen, with real icons, with text, progress, etc. They downgraded my developer PC to a bloody iPhone.
|
|
|
|
|
Dear Sir,
I highly appreciate the work you did for me.
I am not expert as you are but I would like to put some point with you may agree or not.
1. There should not be any suspicion of this document as I put same material as mention in document.
2. You are talking about specification and no text, so, I think command all says that Read version request(send command- 25 52 02 01 DE) - this command we need to send and response command from microcontroller(25 52 0C 01 UHD-4k.02.10.09 C2).
This command just only to see version in the system.
3. I mentioned before that there is 6 keys on the keypad. Key_WB is one of the key. There is command given for the this key:-
Send command to microcontroller- %W 0x03 0x02 0xF3 LRC
Response command from microntroller to PC - % W 0x02 ACK LRC (this command should with ACK byte)
For LRC, LRC value is calculated only for this command , for other keys, I think I have to calculate to put in command.
I did not get the point that you are calculating the response command(%R 0x0C 0x01 UHD-4K 02.10.09 0xC2) instead of input command(0x25 0x52 0x02 0x01 0xDE). The microcontroller is predefined with these commands and when we will send these commands to microcontroller, so, microcontroller should respond as protocol.
Now my question here is that, We need response from microcontroller with ACK byte and for this purpose, how we can write programm in visual studio with c# to send command with GUI and get reposne from microcontroller.
I am sharing again important information to check.
Protocol:-
Request „Read“ :
« %R NUM CMD LRC »
Ex- 0x25 0x52 0x02 0x01 0xDE
Response „Read“:
« %R NUM CMD DATA LRC »
Ex- %R 0x0C 0x01 UHD-4K 02.10.09 0xC2
__________________________________________________________________________
Request „Write“ (Send Command to microcontroller)
« %W NUM CMD Data LRC »
Ex- %W 0x03 0x02 0xF3 LRC (Send Command to microcontroller)
Response „Write“:
« %W NUM STAT LRC »
Ex- % W 0x02 ACK LRC (Response command from microcontroller)
% = Start of message
R/W = Read/Write
CMD = Command
NUM = length of message (all bytes excluding „% R/W NUM“)
DATA = real data
LRC = XOR complete message
STAT = ACK (0x06) = OK
NAK (0x15) = not OK
BUSY (0x07) = in process
In case of negative answer (NACK) the request must be repeated until a positive answer
(ACK) has been received. The delay time for a new request has a minimum of 100ms.
In case of answer (BUSY) the sender has to wait until the answer (ACK) has been
received.
In every case; each request must be answered with an response. The host has to wait on
an response.
I think I have given enough information to understand the logic. I just need advise to write a program for serial communication with c# and get response from microcontroller with ACK byte.
Regards
|
|
|
|
|
You constructed a system with many components (computer, peripheral, cable, software) and that system fails to provide the response you expect. So something is wrong, or even: several things could be wrong.
When debugging a system, there is only one correct attitude: everything is suspect.
The right approach is: start from the facts, not opinions, impressions, gut feelings. And you did not provide many facts, the most important ones are (if I understood you correctly):
- your code receives a command instead of a response (like an echo);
- downloading the firmware was successful;
- the "documentation" is inconsistent.
You care most about one specific command. I don't, I care first about successful communications, I want to see a successful command-response sequence, no matter which command it is. Once you get a reasonable response, you have a new fact, telling you how the NUM, DATA, LRC fields really must be used; the importance of this is stressed by the inconsistency in the "documentation". The simpler the command is, the more likely it is to be accepted; and then you can study the response, as I did for the example version string which does not follow the rules of the "documentation".
I wish you good luck, and hope you will let us know how you made real progress if and when that happens.
Luc Pattyn [My Articles]
The Windows 11 "taskbar" is disgusting. It should be at the left of the screen, with real icons, with text, progress, etc. They downgraded my developer PC to a bloody iPhone.
|
|
|
|
|
I am search for easy way programmatically select step by step button. Because i am devoliping software for disabled people with ALS. And i am beginer in .NET and i need solve this problem.
Hi i am using this function for button select step by step:
<pre lang="C#">
Update_cursor_positions++;
Cursor.Position = new Point((x - 10) + 100 * Update_cursor_positions, (y + 90) + Lines_cursor_positions);
if (Update_cursor_positions >= 10)
{
Update_cursor_positions = 0;
Lines_cursor_positions += 100;
Stop_cursor_move++;
}
if (Stop_cursor_move >= 4)
{
Update_cursor_positions = 0;
Lines_cursor_positions = 0;
Stop_cursor_move = 0;
}
Is posible select button step by step like this ?
for (int i = 0; i < 5; i++)
{
Cursor.Position = PointToScreen(button[i].Location);
} Google and experience
|
|
|
|
|
Quote: Is posible select button step by step like this ?
No. The position as shown would always be the same: the last button in the collection.
I'm not at all sure what exactly you are trying to do, you need to explain in much better detail in order for us to help you.
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
"Common sense is so rare these days, it should be classified as a super power" - Random T-shirt
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
When the program starts.
Move the mouse cursor to the first button.
Then another button and when it ends on the last button.
Will start again.
Move the cursor every second.
|
|
|
|
|
So set up a Timer with an Interval of 1000 and handle the Tick event.
Each Tick, move the cursor.
What's the problem?
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
"Common sense is so rare these days, it should be classified as a super power" - Random T-shirt
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
I think the closest thing you can do is using the tabstop property, and setting the desired tab order.
If you're doing a WinForms app, these are properties in the control designer. If you're doing a WPF app, the tab order is set according to the top-down appearance in the xaml.
".45 ACP - because shooting twice is just silly" - JSOP, 2010 ----- You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010 ----- When you pry the gun from my cold dead hands, be careful - the barrel will be very hot. - JSOP, 2013
|
|
|
|
|
I'm guessing that you want to create a "wizard".
Simple Wizard for WinForms
"Before entering on an understanding, I have meditated for a long time, and have foreseen what might happen. It is not genius which reveals to me suddenly, secretly, what I have to say or to do in a circumstance unexpected by other people; it is reflection, it is meditation." - Napoleon I
|
|
|
|
|
No, it's for ALS / MDN patients (think about how Stephen Hawking selected words / phrases on his computer with only the one "button" he could press).
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
"Common sense is so rare these days, it should be classified as a super power" - Random T-shirt
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
If it was that serious, I would look into gaze tracking / interactions. And I think it depends on the subject.
"Before entering on an understanding, I have meditated for a long time, and have foreseen what might happen. It is not genius which reveals to me suddenly, secretly, what I have to say or to do in a circumstance unexpected by other people; it is reflection, it is meditation." - Napoleon I
|
|
|
|
|
I suspect it's a school project rather than a serious application: his skill level looks to be pretty low ATM.
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
"Common sense is so rare these days, it should be classified as a super power" - Random T-shirt
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
OriginalGriff wrote: MDN patients
I didn't realise users of the Mozilla Developer Network[^] were classed as "patients".
(I suspect you meant "MND", or "get me another coffee".)
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
It's the last one ...
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
"Common sense is so rare these days, it should be classified as a super power" - Random T-shirt
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
Message Removed
modified 6-Jan-22 3:14am.
|
|
|
|
|
Hello,
I have a simple question I think, but do not seem to find an answer easily
I have a lisbox and a gridview. Both are connected to a database through the design editor.
visualisation works, but now I want to show only the items in the gridview which are connected to a chosen item in the listbox.
I already set the listbox to visualize a name and the value member to have the "primary key".
Now I want to show only the items in the gridview who are connected to this primary key.
Inside the design editor I can add a query like this :
SELECT pkID, ProductieVolgorde, Stuknr, Rolnr, AantalMeters, DatumTijd, Status, fkPO
FROM dbo.tblDoek1
WHERE fkPO = @What do I place here?
how do I link the chosen value member of the listbox to this fkPO in the query?
Is there somewhere a simple tutorial on how to link a database fully inside the Design editor?
thanks in advance
|
|
|
|
|
You use the SelectedIndexChanged event of the ListBox, in conjunction with the SelectedItem (as "Type") property, to sync the ListBox with the GridView (filter).
ListBox.SelectedIndexChanged Event (System.Windows.Forms) | Microsoft Docs
"Before entering on an understanding, I have meditated for a long time, and have foreseen what might happen. It is not genius which reveals to me suddenly, secretly, what I have to say or to do in a circumstance unexpected by other people; it is reflection, it is meditation." - Napoleon I
|
|
|
|
|
Hi, there. So you have a listbox with, for example, country names, and you want to display in the datagridview a list only of the cities of the country selected in the listbox. You actually don't need a whole new query for this. This is called a master-detail relationship (so you can google for that), or more precisely, a one-to-many relationship.
In the designer, you can set up a relation between the two tables. Then you use the table adapter to load the tables as usual. But you set the data source of the datagridview to the same binding source of the listbox, with the data member set to the relation. So, the master binding source points to the data table in the data set. Then the detail binding source points to the relation in the master binding source.
On the form, once you set the bindings this way, it's all automatic. When the selected item in the list box changes, the datagridview automatically updates.
A different method is this. Set the master binding source to its master table, and the detail binding source to its detail table. Then, when the selected value in the listbox changes, intercept the event and set a filter on the detail binding source (which is bound to the datagridview).
The first method is mostly done in designer, and the second is done mostly in code. You could create a query for this purpose, but these two methods would generally be more efficient. I hope this helps!
modified 7-Jan-22 18:08pm.
|
|
|
|
|
Hello RobertSF,
that was the asnwer I was looking for thanx!
Will any changes in the gridview be adapted in the database too this way?
edit : I spoke too early when I change the selection in my listbox the application hangs
modified 12-Jan-22 5:53am.
|
|
|
|
|
If the grid is edited, yes, you can propagate the changes to the database. It won't happen automatically. You'll first have to call EndEdit on the binding source and possibly first on the grid, and then use either a table adapter update method or the dataset update method.
It's pretty rare for applications to hang, in my experience. They more often crash with exceptions, though they can also get stuck in infinite loops. Try working with the debugger and going line by line.
Or google for "master detail two datagridview" and try it with two grids instead of listbox and a grid. I don't think I can post link, but the full title of the Microsoft document is "Walkthrough: Creating a Master/Detail Form Using Two Windows Forms DataGridView Controls"
|
|
|
|
|
Maybe this will help. I created an Access database with two tables.
Table: Countries
-string: CountryName
Table: Cities
-string: CountryName
-string: CityName
No relationships created between the two tables. Entered three countries (USA, Canada, Mexico), and three cities in each country.
In Visual Studio, created a new dataset with the two tables from the database. Here, I did create a relationship, linking the Cities table to the Countries table by the CountryName column. The relationship, which exists only in Visual Studio, is called Countries_Cities.
Then I created a form and dropped a ListBox into the form. Setting the DataSource to the Countries table (you must drill down in Designer) automatically creates the countriesBindingSource. Then I set the DisplayMember to CountryName. Here are the binding setting for the ListBox.
this.listBox1.DataSource = this.countriesBindingSource;
this.listBox1.DisplayMember = "CountryName";
Then I dropped a DataGridView into the form. When I clicked the button to select the Data Source, my choices were countriesBindingSource and Other Data Sources. Drill down into countriesBindingSource and select the Countries_Cities relationship. This will automatically create the countriesCitiesBindingSource and will auto-populate the DataGridView with two columns, CountryName and CityName. You can delete the CountryName column. Here are the binding values for the DataGridView.
this.dataGridView1.DataSource = this.countriesCitiesBindingSource;
This is all designer code, so you need not code anything so far. Now run the application. The form should appear, showing the countries in the List Box, but only the cities for the selected country in the DataGridView.
Click on the other countries in the ListBox, and the DataGridView should automatically show only the cities for the selected country. I hope this helps. This stuff can be pretty crazy-making because there are few practical examples to follow.
|
|
|
|
|
This is a program I have been tinkering with for my daughter to help her budget her finances. I understand that there are programs out there, but I wanted something to do and decided to play around with do this.
I am working on the income section, which has income coming in either weekly, semi monthly, bimonthly, monthly or yearly. What I am showing is the weekly section and I am curious as to whether there is a better method, which there usually is to what I am attempting to accomplish.
The "ds.Tables[0].Rows[i][0].ToString()" brings in the test verbiage for whether its weekly, monthly, whatever.
The "f" variable in the for loop is a numerical response provided by the user as to how far out they which to forecast their budget. 4 weeks, 6 weeks, 8 weeks and so forth.
If there is more detail needed, please let me know.
if (ds.Tables[0].Rows[i][0].ToString() == "Weekly (52)")
{
var date = new DateTime(DateTime.Now.Year, DateTime.Now.Month, 1);
for (int x = 1; x < 7; x++)
{
if (ds.Tables[0].Rows[i][1].ToString() != date.ToString("ddd"))
{
DateTime newdate = date.AddDays(1);
date = newdate;
}
else
{
for (int n = 0; n <= ((4*f)-1); n++)
{
list.Add(date);
DateTime newdate = date.AddDays(7);
date = newdate;
}
break;
}
}
}
Thank you,
Richard
Disable Vet
Grandfather
Pain in the @ss
|
|
|
|
|
You refer to your daughter as "the user"? Unless she's a CEO, she could probably get by with Excel; they even have "budget templates".
"Before entering on an understanding, I have meditated for a long time, and have foreseen what might happen. It is not genius which reveals to me suddenly, secretly, what I have to say or to do in a circumstance unexpected by other people; it is reflection, it is meditation." - Napoleon I
|
|
|
|
|
I'd start with something like this:
private static DateTime NextWeekDay(DateTime date, string expectedDayOfWeek, DateTimeFormatInfo dateFormat)
{
int expectedDayIndex = Array.IndexOf(dateFormat.AbbreviatedDayNames, expectedDayOfWeek);
if (expectedDayIndex != -1)
{
int dayOfWeek = (int)date.DayOfWeek;
if (dayOfWeek != expectedDayIndex)
{
int daysToAdd = expectedDayIndex - dayOfWeek;
if (daysToAdd < 0) daysToAdd += 7;
date = date.AddDays(daysToAdd);
}
}
return date;
}
DateTime today = DateTime.Today;
DataTable dt = ds.Tables[0];
DateTimeFormatInfo dateFormat = DateTimeFormatInfo.GetInstance(CultureInfo.CurrentCulture);
foreach (DataRow row in dt.Rows)
{
string budgetType = row[0].ToString();
switch (budgetType)
{
...
case "Weekly (52)":
{
DateTime date = today.AddDays(1 - today.Day);
string expectedDayOfWeek = row[1].ToString();
date = NextWeekDay(date, expectedDayOfWeek, dateFormat);
int max = (4 * f);
for (int n = 0; n < max; n++)
{
list.Add(date);
date = date.AddDays(7);
}
break;
}
...
}
} Further optimisation may be possible depending on what the rest of the code looks like.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
If the code works and it is clear to you, then don't go changing it just for the sake of changing it. I often hear people talking about "improving" code, but they are vague on what improvement actually means in this case. Sure, there are some minor optimisations that jump out but whether or not they are worth putting in is debatable.
|
|
|
|
|