Notifications
Clear all

Scripting feature

batFix
(@batfix)
Reputable Member

It would be great addition to NBLA software.

Reading advises from @djibattworkshop to read certain regs... perhaps adding new feature to NBLA program - simple scripts executing to manipulate with regs -  will provide fast adaptation to new chips and different registers/data 

 

Such program as NBLA software working with so many chips and their modifications, so it's practically impossible include all of them into such program to interpret all commands and responses via SMBus.

It remind me a case with very useful program MHDD for testing hard drives; the author included into it a script interpreter what allow to send other [any] low level cmds or cmds with different/unknown to author data for a moment of compilation his program. 

The scrip could include clear [for customers] comments/outputs to a console/log for easy grasping results.

It's actually giving high flexibility for the programs , reliving a developer from frequent updates his code. As new chips popping up all the time. New registers, new values, etc.

Also, it do help rid of re-typing and making possible mistyping by customers. Say, writing values by mistake into other register could make the chip non-functioning at all.

It would be good feature for professional analyzer.

Lets Make NLBA Great ! Together.

Quote
Topic starter Posted : 21/06/2021 5:34 am
DjiBattWorkshop
(@djibattworkshop)
Member Moderator
Posted by: @batfix

Also, it do help rid of re-typing and making possible mistyping by customers. Say, writing values by mistake into other register could make the chip non-functioning at all

If customer could make misprint in the Smbus tab he could make misprints in the scripts same way, isn't?

Or scripts should be precompiled by developer?

Then there are hunderds of registers in the chips which will make Script menu confusing and overloaded especially for newbie customers. How they will know which button to press and for which chip, having in view MAC registers handling require deep knowledge in smart battery field. My guess they will start pressing literally everything to get chip working or .... until they brick something else.

And how they will interpret received responses?)

Posted by: @batfix

Reading advises from @djibattworkshop to read certain regs...

Most of advices given by me here were related to sending Chip AutoDetect OpCodes to verify actual chip on wire, because online battery database has some errors and collisions. Also fake batteries has cloned Static parameters and chip shown not correctly for them, because they normally using different low cost emulators.

 This feature built into Nlba first page could be extremely useful for both customers and support team. So it could display Expected Chip and Detected Chip in Static Parameters area. It will save hours on both sides in asking unnecessary questions. And yes, this feature request was sent to development department long time ago.

But even within TI chips those registers are not universal and changing from generation to generation, and from firmware to firmware (TI, Sanyo, Sony etc) making difficulties for programmers in the implementation of this useful feature.

Another chip vendors like Renesas or Maxim Integrated have completely different mechanism of chip detection or not have it at all because there is no public documentation on how it works which explains once again why this option is not universal and could not be easy implemented.

 

 

ReplyQuote
Posted : 21/06/2021 9:17 am
batFix
(@batfix)
Reputable Member

Those scripts, for start, could come from you or someone with same knowledge, as a secure form to obtain more data, for clarification as you doing here many times. Instead of text what need to c&p...

If some advanced customer want to make his own script, he should/will read manuals, ask for advise, etc. Some of such repeatable question posting here, would be convert in one common script with meaningful name, reflecting model, version, maker, etc

No, scripts will be interpret by relevant routine of the NBLA software, it would be much harder to make additional compiler. Look, I'm came from that fields where complicated software using scripts as ad-hoc extension in case of new chips, bits, etc. I mentioned already MACCOR SW and devices...

Scripts have no menu, it's really flexible feature. Let me post those MHDD examples.

This sample demonstrate test form of commands using as a script:

;version - do not change
V1.1

;confirmations: on
ASK_ON

terminate batch on error
HALT_ON

;make sound after each line
ENDSND_ON

;select a drive (menu)
DRV_SELECT

;ata reset
DRV_RESET

;Seek Test 10 seconds
DRV_SEEK 10

;repeat NEXT line 2 times
REPEAT 2

;scan whole drive without repair
DRV_SCAN MIN MAX 0

;stop spindle
DRV_STOP

Another sample - low level cmds with registers (similar to SMBus)

disabledebug ; comment this out to see every string execution

print " \02þ\07 Spinup"
regs = $07 00 00 00 00 $e0 $ef

waitnbsy
checkerr

print " \02þ\07 Disable Standby"
regs = $86 00 00 00 00 $e0 $ef

waitnbsy
checkerr

Lets Make NLBA Great ! Together.

ReplyQuote
Topic starter Posted : 21/06/2021 12:13 pm
batFix
(@batfix)
Reputable Member

More advanced sample:

;
; MHDD TERMINAL: Sample scripting batch and documentation
; Please also look at "STEST" for SCSI commands
; and "IDESCAN" for an advanced example
;
; ---------------------------------------------------------------------
; You can use symbols ";", "#", "//" to comment out anything
; ---------------------------------------------------------------------
;
;
; Variables:
; -----------------------------------------------------------------
; You can use variables without declaration. Variable name should
; start with "%" and contain only symbols. Names are not case sensitive.
;
; An example of using variables:
;
; %a = 4
; %myvariable = %a + 10
; print "Result = %myvariable"
;
; You can also assign any string to a variable.
; Please do not use quotes when assigning a string.
;
; %cmdread = 00 100 00 00 00 $e0 $20
; regs = %cmdread
;
;
; Labels/loops/if example:
; -------------------------------------------------------------------
; %a = 0
; @loop:
; %a = %a + 1
; print "A = %a"
; if %a = 10 @end
; goto @loop
; @end:
; print "\15Finished."
;
;
; All commands except SCSI (for SCSI commands please look into file STEST)
; -------------------------------------------------------------------
;
; Rx = yy put yy into register x
;
; REGS = yy1 yy2 yy3 yy4 yy5 yy6 yy7 // for LBA28 mode
; REGS48 = yy1 yy2 yy3 yy4 yy5 yy6 yy7 // for LBA48 mode
; put everything to registers
; hex values format: $xx, i.e. $FF
; To use LBA48 mode, use REGS48 instead of REGS
;
; REGS_PUTLBA28 put LBA to registers R3..R6, also clears R2
; please do not forget to set R2 after calling this
; procedure
;
; WAITNBSY wait-for-not-busy, i.e., wait for drive ready
;
; CHECKDRQ check for DRQ, exit if no DRQ
;
; CHECKERR check for ERROR, exit if ERROR
;
; CHECKESC check ESC pressed
;
; RESET reset the drive (need WAITNBSY after)
;
; SECTORSTO = xx
; read sectors from drive's data register
; to file xx (xx = filename)
; SECTORSFROM = xx
; write sectors to drive's data register
; from file xx (xx = filename)
;
; PRINT = "text"
; prints some text (text should be in quotes)
; see examples below on how to use colors
;
; XPRINT = "text"
; prints some text (text should be in quotes)
; printing always starts from the start of current
; line
;
; DISABLEDEBUG disables line-by-line output to the screen
; (useful if you use PRINT to put messages)
;
; TERMINATE terminate script (useful to for debugging)
; program will stop at this point
;
; GOTO @label goes to label
;
; IF <expr> @label
; if <expression> is true then goto @label
; example: if %myvariable = 3 @end
;
; Functions
; -------------------------------------------------------------------
;
; USERINPUT takes a string from keyboard
;
; ISERROR checks if error happened or no
;
; REGS_GETLBA28 gets LBA from registers R3..R6
; used to get error LBA number after an error
;
; Functions can be used only like this:
; %myvariable = USERINPUT ; this will put user input
; ; into the variable
;
; %myvariable = ISERROR ; this will return "1" in case of
; ; error or "0" if no error
; ------------------------------------------------------------------
;
; Following example will do:
; 1. device reset
; 2. identify device
; 3. read 100 sectors starting from lba 0
;
; To see more complicated example please look into "IDETEST" script
; ------------------------------------------------------------------

disabledebug ; comment this out to see every string execution
print = "^01 \14þ\15 Simple test script"
; *******************************************************
; * Reset *
; ****************************************************

print " \02þ\07 Reset..."
reset
waitnbsy
; terminate ; uncomment this to stop at this point

;
****************************************************
; * Device identify *
; ****************************************************

print " \02þ\07 Getting identify information"
r7 = $EC
waitnbsy
checkerr
checkdrq
sectorsto = identify.bin
print " \15û\07 identify.bin has been written"

;
****************************************************
; * Read 100 sectors starting from LBA 0 *
; ****************************************************

print " \02þ\07 Reading 100 sectors starting from LBA 0"
regs = 00 100 00 00 00 $e0 $20
waitnbsy
checkerr
checkdrq
sectorsto = lba0-99.bin
print " \15û\07 lba0-99.bin has been written"
print "^01 \14þ\15 Everything is done."

;
****************************************************
; * End of script *
; *******************************************************

Lets Make NLBA Great ! Together.

ReplyQuote
Topic starter Posted : 21/06/2021 12:19 pm
batFix
(@batfix)
Reputable Member

You can name it as batch mode or unattended mode if you need run say a few tabs: Discharge, Charge, Test Cells, Calibrating in a row while you are busy doing other tasks.

Lets Make NLBA Great ! Together.

ReplyQuote
Topic starter Posted : 21/06/2021 12:32 pm
Nicusor
(@azzido)
Member Admin
Posted by: @batfix

It would be great addition to NBLA software.

Reading advises from @djibattworkshop to read certain regs... perhaps adding new feature to NBLA program - simple scripts executing to manipulate with regs -  will provide fast adaptation to new chips and different registers/data 

 

Such program as NBLA software working with so many chips and their modifications, so it's practically impossible include all of them into such program to interpret all commands and responses via SMBus.

It remind me a case with very useful program MHDD for testing hard drives; the author included into it a script interpreter what allow to send other [any] low level cmds or cmds with different/unknown to author data for a moment of compilation his program. 

The scrip could include clear [for customers] comments/outputs to a console/log for easy grasping results.

It's actually giving high flexibility for the programs , reliving a developer from frequent updates his code. As new chips popping up all the time. New registers, new values, etc.

Also, it do help rid of re-typing and making possible mistyping by customers. Say, writing values by mistake into other register could make the chip non-functioning at all.

It would be good feature for professional analyzer.

Let's analyze a bit this request. The request is to implement a parser, a command-line interpreter and executer into NLBA1 software. An example of a potential benefit would be to execute custom commands for different chips like reading the firmware version.

Ok, so, Why does NLBA1 software has already implemented the handling of SMBus commands like SendCommand, ReadWord, WriteWord, ReadBlock, WriteBlock and even Write 2 Blocks ? Exactly for this use case, when someone wants to send a customer command. In principle, it is used by us to help customers (sending custom commands to find out more information, sending custom commands to exit a chip from Boot Mode and so on). The customer can also use this feature to send what commands he wants but in principle 99% of users does not know what commands to send.

A script consists of multiple commands, interpreted, executed, the value from command line1 passed to command line2, timeout, etc. A script would be useful when multiple commands are needed to sent. Up to know, all commands from this forum can be easily executed in already existing feature. There is no sequence of commands that needed to be sent. 

Give me an example of when you would need a script.

NLBA Laptop Battery Analyzer with Chip Reset & Repair Option

ReplyQuote
Posted : 21/06/2021 1:21 pm
Share: