Merge pull request #229 from evil-mad/feature/Issue_228_RemoveParamNumFromQU

Feature/issue 228 remove param num from qu
pull/231/head
Brian Schmalz 2024-05-07 08:44:30 -05:00 zatwierdzone przez GitHub
commit c84ebaefad
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: B5690EEEBB952194
21 zmienionych plików z 19072 dodań i 11925 usunięć

Plik binarny nie jest wyświetlany.

Wyświetl plik

@ -0,0 +1,318 @@
Uses "UI"
Uses "CONSOLE"
Uses "COMM"
Uses "WMI"
Uses "OS"
'---Constant declarations
Begin ControlID
%ID_StartUpdateButton
%ID_ExitButton
%ID_CommandOutputTexBox
%IDC_TIMER
End ControlID
%TIMER_DELAY = 100 '---Timer delay (in milliseconds, not very accurate below about 100)
Global hComm As Long
Global nBytes As Long
Global sBuffer As String
Global gPortOpen As Boolean
Global pID As Number
Global vData() As String
Global nItems As Long
Global Counter As Long
Global Position As Long
Global ComputerName As String Value OS_GetComputerName
Global Ports() As String
Global CountATI As Long
Global sHexFilename As String
Global sFirmwareNumber As String
Global bConsole As Boolean
Global bUpdaterConsole As Boolean
Global sCommandLine As String
' Replace the filename in the next two lines to change which HEX file gets programmed
#BUNDLE File "HEX", ".\EBF_v302.hex", "", ReplaceExisting=1
sFirmwareNumber = "3.0.2"
bConsole = TRUE ' for normal printfs
bUpdaterConsole = TRUE ' for mphidflash
sHexFilename = "EBF_v" & Replace$(sFirmwareNumber, ".", "") & ".hex"
#BUNDLE File "app", ".\mphidflash-1.6-win-32.exe", "", ReplaceExisting=1
#BUNDLE Icon "WhiteEBBv20.ico"
'------------------------------------------------------------------------------
' Program start point
'------------------------------------------------------------------------------
Function TBMain() As Long
Local hDlg As DWord '---Used to store window handle of main dialog
gPortOpen = FALSE
'---Create a new dialog
hDlg = Dialog_New Pixels, 0, "EBB Update to firmware v" & sFirmwareNumber, -1, -1, 400, 400,
%WS_DLGFRAME |
%DS_CENTER |
%WS_CAPTION |
%WS_SYSMENU |
%WS_OVERLAPPEDWINDOW
'---Set window minimum size
Dialog Set Minsize hDlg, 400, 400
'---Show dialog in modal mode
'---cbDialog function is the callback function handling dialog events
'---Application control will pass to dialog callback till dialog will exists
Dialog Show Modal hDlg, Call cbDialog
'---If execution comes here it means main dialog as been destroyed
If (bConsole) Then Console_WriteLine "---Application finished ---"
End Function
'------------------------------------------------------------------------------
' Callback procedure for main window
'------------------------------------------------------------------------------
CallBack Function cbDialog() As Long
'If (bConsole) Then Console_Writeline CBHNDL, CBCTL, CBCTLMSG, CBLPARAM, CBWPARAM
Select Case CBMSG
Case %WM_CREATE
If (bConsole) Then Console_WriteLine Time$, "Fired %WM_CREATE dialog message"
Case %WM_INITDIALOG
If (bConsole) Then Console_WriteLine Time$, "Fired %WM_INITDIALOG dialog message"
'---Add controls
Control Add Button, CBHNDL, %ID_StartUpdateButton, "Start Update", 160, 10, 80, 25, %BS_NOTIFY | %WS_TABSTOP Call cbButton
Control Add Button, CBHNDL, %ID_ExitButton, "Exit" , 160, 350, 80, 25, %BS_NOTIFY | %WS_TABSTOP Call cbButton
Control Add Textbox, CBHNDL, %ID_CommandOutputTexBox, "" , 10, 40, 380, 300, %ES_MULTILINE | %ES_AUTOVSCROLL | %WS_HSCROLL | %ES_AUTOHSCROLL | %WS_VSCROLL |%ES_READONLY
Case %WM_COMMAND
'If (bConsole) Then Console_Writeline Time$, "Fired %WM_COMMAND dialog message", CBCTL
Case %WM_SIZE '---The WM_SIZE message is sent to a window after its size has changed.
'If (bConsole) Then Console_Writeline Time$, "Fired %WM_SIZE dialog message", CBWPARAM, LOWRD(CBLPARAM), HIWRD(CBLPARAM)
Case %WM_SIZING '---The WM_SIZING message is sent to a window that the user is resizing.
'If (bConsole) Then Console_Writeline Time$, "Fired %WM_SIZING dialog message", CBWPARAM, LOWRD(CBLPARAM), HIWRD(CBLPARAM)
Case %WM_MOVE
'If (bConsole) Then Console_Writeline Time$, "Fired %WM_MOVE dialog message", LO(Integer, CBLPARAM), HI(Integer, CBLPARAM)
Case %WM_DESTROY
'---Do whatever needed just before dialog is destroyed.
If gPortOpen = TRUE Then
gPortOpen = FALSE
COMM_Close(hComm)
End If
'If (bConsole) Then Console_Writeline Time$, "Fired %WM_DESTROY dialog message"
Case %WM_TIMER
Select Case CBWPARAM
Case %IDC_TIMER
'' If gPortOpen = TRUE Then
'' nBytes = COMM_Get(hComm, %COMM_RXQUE)
'' COMM_Recv(hComm, nBytes, sBuffer)
'' add_new_bytes(sBuffer, CBHNDL)
'' EndIf
End Select
End Select
End Function
function DoFirmwareUpdate() as Long
sCommandLine = "mphidflash-1.6-win-32.exe -r -w " & sHexFilename
If (bConsole) Then Console_WriteLine sCommandLine
If (bUpdaterConsole) Then
pID = OS_Shell(sCommandLine, %OS_WNDSTYLE_NORMAL, %OS_SHELL_SYNC)
Else
pID = OS_Shell(sCommandLine, %OS_WNDSTYLE_HIDE, %OS_SHELL_SYNC)
EndIf
Sleep 2000
If (bConsole) Then Console_WriteLine("pID = " & pID)
DoFirmwareUpdate = pID
end function
'------------------------------------------------------------------------------
' Callback procedure for button control
'------------------------------------------------------------------------------
CallBack Function cbButton() As Long
Local sComPort As String
Local sTemp As String
Local dFloat As Double
If CBMSG = %WM_COMMAND Then
Select Case CBCTLMSG
Case %BN_CLICKED
Select Case CBCTL
Case %ID_StartUpdateButton
Control Append Text CBHNDL, %ID_CommandOutputTexBox, "Building a list of EBB COM ports ..." + Chr$(13) + Chr$(10)
sBuffer = WMI_GetData(ComputerName, "", "", "", "Win32_PnPEntity", "", "Name" )
nItems = Parse( sBuffer, vData(), $CRLF)
ReDim Ports()
For Counter = 1 To nItems
Position = InStr(Ucase$(vData(Counter)),"(COM")
If Position Then
console_printLine(vData(Counter))
Console_printLine(Ucase$(vData(Counter-1)))
' If we have a "COMxx" port, then look for the PID/VID of EBB
If InStr(Ucase$(vData(Counter-1)), "VID_04D8&PID_FD92") Then
ReDim Preserve Ports(UBound(Ports)+1)
Ports(UBound(Ports)) = Extract$(Position+1,vData(Counter),")")
Console_PrintLine(Ports(UBound(Ports)))
End If
End If
Next
' Check for no COM ports found
If LBound(Ports) = 1 And UBound(Ports) = 1 Then
Control Append Text CBHNDL, %ID_CommandOutputTexBox, "No EBB COM ports found on this computer." + Chr$(13) + Chr$(10)
Control Append Text CBHNDL, %ID_CommandOutputTexBox, "Attempting recovery update directly into bootloader mode..." + Chr$(13) + Chr$(10)
if (DoFirmwareUpdate() <> 0) then
Control Append Text CBHNDL, %ID_CommandOutputTexBox, "Update failed. Click Exit." + Chr$(13) + Chr$(10)
else
Control Append Text CBHNDL, %ID_CommandOutputTexBox, "Update succeded. Click Exit to quit," + Chr$(13) + Chr$(10)
Control Append Text CBHNDL, %ID_CommandOutputTexBox, "or click Start Update to restart normal firmware update process." + Chr$(13) + Chr$(10)
endif
Else
Control Append Text CBHNDL, %ID_CommandOutputTexBox, "Found the following EBB COM ports:" + Chr$(13) + Chr$(10)
For Counter = LBound(Ports) To UBound(Ports)
Control Append Text CBHNDL, %ID_CommandOutputTexBox, Ports(Counter) + Chr$(13) + Chr$(10)
Next
For Counter = LBound(Ports) To UBound(Ports)
hComm = COMM_FreeFile
Control Append Text CBHNDL, %ID_CommandOutputTexBox, "Testing port " & Ports(Counter) & " ... "
COMM_Open("\\.\" & Ports(Counter), hComm)
If Err = 0 Then
COMM_Set(hComm, %COMM_BAUD, 123)
COMM_Print(hComm, "V" & Chr$(13))
Sleep 100
nBytes = COMM_Get(hComm, %COMM_RXQUE)
COMM_TRecv(hComm, nBytes, sBuffer, 1000)
COMM_Print(hComm, "V" & Chr$(13))
Sleep 100
nBytes = COMM_Get(hComm, %COMM_RXQUE)
COMM_TRecv(hComm, nBytes, sBuffer, 1000)
sBuffer = Trim$(sbuffer, Any Chr$(13) & Chr$(10))
If LEFT$(sBuffer, 3) = "EBB" Then
Control Append Text CBHNDL, %ID_CommandOutputTexBox, "Found an EBB with firmware version " & RIGHT$(sBuffer, 5) + Chr$(13) + Chr$(10)
Control Append Text CBHNDL, %ID_CommandOutputTexBox, "Attempting update to version " & sFirmwareNumber + Chr$(13) + Chr$(10)
COMM_Print(hComm, "BL" & Chr$(13))
Sleep 1000
COMM_Close(hComm)
Sleep 5000
DoFirmwareUpdate()
Sleep 2000
If pID = 0 Then
COMM_Open("\\.\" & Ports(Counter), hComm)
If Err = 0 Then
COMM_Print(hComm, "V" & Chr$(13))
Sleep 500
nBytes = COMM_Get(hComm, %COMM_RXQUE)
COMM_TRecv(hComm, nBytes, sBuffer, 1000)
COMM_Print(hComm, "V" & Chr$(13))
Sleep 500
nBytes = COMM_Get(hComm, %COMM_RXQUE)
COMM_TRecv(hComm, nBytes, sBuffer, 1000)
sBuffer = Trim$(sBuffer, Any Chr$(13) & Chr$(10))
If (RIGHT$(sBuffer,5) = sFirmwareNumber) Then
Control Append Text CBHNDL, %ID_CommandOutputTexBox, "Updated to version " & RIGHT$(sBuffer,5) & " successfully" + Chr$(13) + Chr$(10)
Else
Control Append Text CBHNDL, %ID_CommandOutputTexBox, "Incorrect version detected. EBB=" & RIGHT$(sBuffer,5) & " File=" & sFirmwareNumber & " Updated failed." + Chr$(13) + Chr$(10)
EndIf
COMM_Close(hComm)
EndIf
Else
Control Append Text CBHNDL, %ID_CommandOutputTexBox, "Programming EBB failed with an error." + Chr$(13) + Chr$(10)
EndIf
Else
Control Append Text CBHNDL, %ID_CommandOutputTexBox, " no EBB found" + Chr$(13) + Chr$(10)
'If (bConsole) Then Console_WriteLine("...closing port " & "\\.\" & Ports(Counter))
COMM_Close(hComm)
EndIf
Else
Control Append Text CBHNDL, %ID_CommandOutputTexBox, "Error: " & Err + Chr$(13) + Chr$(10)
End If
Next
Control Append Text CBHNDL, %ID_CommandOutputTexBox, "Click Exit (or click Start Upgrade again to update more EBBs)" + Chr$(13) + Chr$(10)
End If
Case %ID_ExitButton
If (bConsole) Then Console_WriteLine Time$, "CloseCommButton"
If gPortOpen = TRUE Then
gPortOpen = FALSE
COMM_Close(hComm)
End If
If (bConsole) Then Console_WriteLine("port closed")
Dialog End CBHNDL
End Select
End Select
'---If button callback does not return %TRUE, message is passed
'---to parent window
Function = %TRUE
End If
End Function
' Take new string from com port, look for CR/LF
' Then handle the line based on first character
Function add_new_bytes(sNewBytes As String, hndl As Long)
Local x As Long
For x = 1 To Len(sNewBytes)
sCurrentLine = sCurrentLine + Mid$(sNewBytes, x, 1)
If RIGHT$(sCurrentLine, 1) = Chr$(13) Then
' We have a new line
If LEFT$(sCurrentLine, 1) = "~" Then
handle_PI_line(sCurrentLine, hndl)
Else
handle_normal_line(sCurrentLine, hndl)
End If
sCurrentLine = ""
End If
Next x
End Function
Function handle_normal_line(sNormalLine As String, hndl As Long)
Control Append Text hndl, %ID_CommandOutputTexBox, sNormalLine + Chr$(13) + Chr$(10)
If (bConsole) Then Console_Write sNormalLine + Chr$(10)
End Function
' We need to write slowly so that we don't over-run the handle's one-byte buffer
Function write_to_com(sLine As String, hndl As Long)
Local StartTime As Long
Local x As Long
sLine = sLine + Chr$(13)
For x = 1 To Len(sLine)
StartTime = GetTickCount
While (StartTime + 10) > GetTickCount
Wend
COMM_Send(hComm, Mid$(sLine, x, 1))
Next x
Control Append Text hndl, %ID_CommandOutputTexBox, sLine + Chr$(10)
If (bConsole) Then Write sLine + Chr$(10)
End Function

Plik diff jest za duży Load Diff

Plik binarny nie jest wyświetlany.

Plik binarny nie jest wyświetlany.

Wyświetl plik

@ -21,6 +21,11 @@
<itemPath>source/usb_config.h</itemPath>
<itemPath>source/ebb_print.h</itemPath>
</logicalFolder>
<logicalFolder name="ExternalFiles"
displayName="Important Files"
projectFiles="true">
<itemPath>Makefile</itemPath>
</logicalFolder>
<logicalFolder name="LibraryFiles"
displayName="Library Files"
projectFiles="true">
@ -52,11 +57,6 @@
<itemPath>source/ebb_print.c</itemPath>
<itemPath>source/squareroot.s</itemPath>
</logicalFolder>
<logicalFolder name="ExternalFiles"
displayName="Important Files"
projectFiles="false">
<itemPath>Makefile</itemPath>
</logicalFolder>
</logicalFolder>
<sourceRootList>
<Elem>source</Elem>

Wyświetl plik

@ -151,7 +151,7 @@ volatile UINT16 g_StepperDisableTimeoutS; // Seconds of no motion before m
volatile UINT16 g_StepperDisableSecondCounter; // Counts milliseconds up to 1 s for stepper disable timeout
volatile UINT16 g_StepperDisableCountdownS; // After motion is done, counts down in seconds from g_StepperDisableTimeoutS to zero
const rom char st_version[] = {"EBBv13_and_above EB Firmware Version 3.0.1.1"};
const rom char st_version[] = {"EBBv13_and_above EB Firmware Version 3.0.2"};
#pragma udata ISR_buf = 0x100
volatile unsigned int ISR_A_FIFO[16]; // Stores the most recent analog conversions
@ -2267,7 +2267,7 @@ void parse_CU_packet(void)
// certain values from the EBB.
// "QU,<parameter_number><CR>"
// Returns: Some value(s), dependant on what parameter_number is.
// <parameter_number> <return_packet>
// <return_packet>
// 1 QU,1,XX where XX is a value from 00 to FF, representing the contents of
// the PortB pins at the time of the last limit switch trigger
// 2 QU,2,ddd to read back the maximum supported FIFO length for this version
@ -2297,8 +2297,6 @@ void parse_QU_packet(void)
// Returns "QU,1,XX" where XX is two digit hex value from 00 to FF
if (1u == parameter_number)
{
ebb_print_uint(parameter_number);
ebb_print_char(',');
ebb_print_hex(gLimitSwitchPortB, 2);
print_line_ending(kLE_NORM);
}
@ -2306,8 +2304,6 @@ void parse_QU_packet(void)
// Returns "QU,2,ddd" where ddd is one to three digit decimal value from 0 to 255
else if (2u == parameter_number)
{
ebb_print_uint(parameter_number);
ebb_print_char(',');
ebb_print_uint(COMMAND_FIFO_MAX_LENGTH);
print_line_ending(kLE_NORM);
}
@ -2315,8 +2311,6 @@ void parse_QU_packet(void)
// Returns "QU,3,ddd" where ddd is one to three digit decimal value from 0 to 255
else if (3u == parameter_number)
{
ebb_print_uint(parameter_number);
ebb_print_char(',');
ebb_print_uint(gCurrentFIFOLength);
print_line_ending(kLE_NORM);
}
@ -2324,16 +2318,12 @@ void parse_QU_packet(void)
else if (4u == parameter_number)
{
check_high_water();
ebb_print_uint(parameter_number);
ebb_print_char(',');
ebb_print_hex(gStackHighWater, 3);
print_line_ending(kLE_NORM);
}
// CU,5 prints out current stack high water value and resets it to zero
else if (5u == parameter_number)
{
ebb_print_uint(parameter_number);
ebb_print_char(',');
ebb_print_hex(gStackHighWater, 3);
print_line_ending(kLE_NORM);
INTCONbits.GIEL = 0; // Turn low priority interrupts off
@ -2343,32 +2333,24 @@ void parse_QU_packet(void)
// CU,6 prints out the number of commands currently waiting in the FIFO
else if (6u == parameter_number)
{
ebb_print_uint(parameter_number);
ebb_print_char(',');
ebb_print_uint(gFIFOLength);
print_line_ending(kLE_NORM);
}
// 60 QU,60,dddd prints out current value of g_PowerMonitorThresholdADC
else if (60u == parameter_number)
{
ebb_print_uint(parameter_number);
ebb_print_char(',');
ebb_print_uint(g_PowerMonitorThresholdADC);
print_line_ending(kLE_NORM);
}
// 61 QU,61,dddddd prints out current value of g_StepperDisableTimeoutS
else if (61u == parameter_number)
{
ebb_print_uint(parameter_number);
ebb_print_char(',');
ebb_print_uint(g_StepperDisableTimeoutS);
print_line_ending(kLE_NORM);
}
// 200 QU,200,dddddddddd,dddddddddd prints out the current value of acc_union[0] and acc_union[1] (the accumulators)
else if (200u == parameter_number)
{
ebb_print_uint(parameter_number);
ebb_print_char(',');
INTCONbits.GIEH = 0; // Turn high priority interrupts off
ebb_print_uint(acc_union[0].value);
ebb_print_char(',');

Wyświetl plik

@ -1,5 +1,5 @@
MPLINK 5.00, LINKER
Linker Map File - Created Tue Apr 02 21:10:59 2024
Linker Map File - Created Mon May 06 21:26:09 2024
Section Info
Section Type Address Location Size(Bytes)

Wyświetl plik

@ -465,6 +465,30 @@
</ul>
</p>
<h4>3.0.1 &mdash; 04/02/23</h4>
<p>
<ul>
<li>
<a href="https://github.com/evil-mad/EggBot/issues/223">Issue #223</a> Added a new <code>TD</code> command to create a faster way to execute two T3 commands back to back to create S-curves.
</li>
<li>
<a href="https://github.com/evil-mad/EggBot/issues/222">Issue #222</a> Added a new <code>SP,2</code> and <code>SP,3</code> commands to immediately raise the pen (without going through the FIFO).
</li>
<li>
<a href="https://github.com/evil-mad/EggBot/issues/221">Issue #221</a> Added a new <code>QU,6</code> command to query the current number of moves in the FIFO (i.e. how 'full' the FIFO is).
</li>
</ul>
</p>
<h4>3.0.2 &mdash; 05/06/24</h4>
<p>
<ul>
<li>
<a href="https://github.com/evil-mad/EggBot/issues/228">Issue #228</a> Removed 'Param_Number' in replies to the <code>QU</code> command to simplify PC side parsing of replies.
</li>
</ul>
</p>
<p/>
<hr/>
<p/>

Wyświetl plik

@ -462,7 +462,7 @@
<li><span style="font-weight: bold;">Execution:</span> Immediate</li>
<li>
<span style="font-weight: bold;">Description:</span>
<p>This command zeroes out (i.e. clears) the global motor 1 step position and global motor 2 step position.</p>
<p>This command zeros out (i.e. clears) the global motor 1 step position and global motor 2 step position. It also zeros out both step accumulators.</p>
<p>See the <code><a href="#QS">QS</a></code> command for a description of the global step positions.</p>
</li>
</ul>
@ -2062,8 +2062,8 @@
<ul>
<li><span style="font-weight: bold;">Command: </span><code>QU,<i>Param_Number</i>&lt;CR&gt;</code></li>
<li><span style="font-weight: bold;">Response (future mode): </span><code>QU,<i>Param_Number</i>,<i>Return_Value</i>&lt;NL&gt;</code></li>
<li><span style="font-weight: bold;">Response (legacy mode; default): </span><code>QU,<i>Param_Number</i>,<i>Return_Value</i>&lt;CR&gt;&lt;NL&gt;OK&lt;CR&gt;&lt;NL&gt;</code></li>
<li><span style="font-weight: bold;">Response (future mode): </span><code>QU,<i>Return_Value</i>&lt;NL&gt;</code></li>
<li><span style="font-weight: bold;">Response (legacy mode; default): </span><code>QU,<i>Return_Value</i>&lt;CR&gt;&lt;NL&gt;OK&lt;CR&gt;&lt;NL&gt;</code></li>
<li><span style="font-weight: bold;">Firmware versions: </span>v3.0 and above</li>
<li><span style="font-weight: bold;">Execution: </span>Immediate</li>
<li>
@ -2831,17 +2831,16 @@
This command is for creating specially-crafted back-to-back time-limited moves with jerk. Internally, the <code>TD</code> command takes its parameter values and creates
two <code>T3</code> commands that are loaded into the FIFO. It is a faster way to create "S-curves" accelerations than sending two <code>T3</code> commands separately.
</p>
<p>The <code>TD</code> command loads the two <code>T3</code> commands as follows:
<OL>
<LI>
<code>T3,Intervals,Rate1A,0,Jerk1,Rate2A,0,Jerk2[,Clear]&lt;CR&gt;</code>
</LI>
<LI>
<code>T3,Intervals,Rate1B,Accel1,-Jerk1,Rate2B,Accel2,-Jerk2[,Clear]&lt;CR&gt;</code>
</LI>
</OL>
</p>
<p>The <code>TD</code> command loads the two <code>T3</code> commands as follows:
<ol>
<li>
<code>T3,Intervals,Rate1A,0,Jerk1,Rate2A,0,Jerk2[,Clear]&lt;CR&gt;</code>
</li>
<li>
<code>T3,Intervals,Rate1B,Accel1,-Jerk1,Rate2B,Accel2,-Jerk2[,Clear]&lt;CR&gt;</code>
</li>
</ol>
</p>
<li>
<span style="font-weight: bold;">Example 1:</span>