added check if keycard at the encoder position before trying to encode key
This commit is contained in:
parent
e1549dda2f
commit
f570941b74
@ -299,6 +299,7 @@ func (c *Client) DispenserStart(ctx context.Context) (string, error) {
|
|||||||
deadline := time.Now().Add(3 * time.Second)
|
deadline := time.Now().Add(3 * time.Second)
|
||||||
|
|
||||||
for {
|
for {
|
||||||
|
time.Sleep(delay)
|
||||||
if time.Now().After(deadline) {
|
if time.Now().After(deadline) {
|
||||||
return stockStatus, fmt.Errorf("[%s] timeout waiting keycard at encoder position", funcName)
|
return stockStatus, fmt.Errorf("[%s] timeout waiting keycard at encoder position", funcName)
|
||||||
}
|
}
|
||||||
@ -319,8 +320,6 @@ func (c *Client) DispenserStart(ctx context.Context) (string, error) {
|
|||||||
if isAtEncoderPosition(status) {
|
if isAtEncoderPosition(status) {
|
||||||
return stockStatus, nil
|
return stockStatus, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
time.Sleep(100 * time.Millisecond)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -333,8 +332,13 @@ func (c *Client) DispenserFinal(ctx context.Context) (string, error) {
|
|||||||
return stockStatus, fmt.Errorf("[%s] out of mouth: %w", funcName, err)
|
return stockStatus, fmt.Errorf("[%s] out of mouth: %w", funcName, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
time.Sleep(200 * time.Millisecond)
|
time.Sleep(delay)
|
||||||
|
status, err := c.do(ctx, cmdStatus)
|
||||||
|
if err == nil && len(status) >= 4 {
|
||||||
|
c.setStock(status)
|
||||||
|
}
|
||||||
|
|
||||||
|
time.Sleep(delay)
|
||||||
if err := c.ToEncoder(ctx); err != nil {
|
if err := c.ToEncoder(ctx); err != nil {
|
||||||
return stockStatus, fmt.Errorf("[%s] to encoder: %w", funcName, err)
|
return stockStatus, fmt.Errorf("[%s] to encoder: %w", funcName, err)
|
||||||
}
|
}
|
||||||
@ -343,20 +347,22 @@ func (c *Client) DispenserFinal(ctx context.Context) (string, error) {
|
|||||||
logStatus(status)
|
logStatus(status)
|
||||||
}()
|
}()
|
||||||
|
|
||||||
deadline := time.Now().Add(3 * time.Second)
|
deadline := time.Now().Add(6 * time.Second)
|
||||||
|
|
||||||
for {
|
for {
|
||||||
|
time.Sleep(delay * 2)
|
||||||
if time.Now().After(deadline) {
|
if time.Now().After(deadline) {
|
||||||
return stockStatus, nil
|
return stockStatus, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
status, err := c.do(ctx, cmdStatus)
|
status, err = c.do(ctx, cmdStatus)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return stockStatus, nil
|
return stockStatus, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
stockStatus = stockTake(status)
|
stockStatus = stockTake(status)
|
||||||
c.setStock(status)
|
c.setStock(status)
|
||||||
|
logStatus(status)
|
||||||
|
|
||||||
if isCardWellEmpty(status) {
|
if isCardWellEmpty(status) {
|
||||||
return stockStatus, fmt.Errorf(stockStatus)
|
return stockStatus, fmt.Errorf(stockStatus)
|
||||||
@ -365,8 +371,5 @@ func (c *Client) DispenserFinal(ctx context.Context) (string, error) {
|
|||||||
if isAtEncoderPosition(status) {
|
if isAtEncoderPosition(status) {
|
||||||
return stockStatus, nil
|
return stockStatus, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
time.Sleep(100 * time.Millisecond)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
2
main.go
2
main.go
@ -29,7 +29,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
buildVersion = "1.2.3"
|
buildVersion = "1.2.4"
|
||||||
serviceName = "hardlink"
|
serviceName = "hardlink"
|
||||||
pollingFrequency = 8 * time.Second
|
pollingFrequency = 8 * time.Second
|
||||||
)
|
)
|
||||||
|
|||||||
@ -2,6 +2,9 @@
|
|||||||
|
|
||||||
builtVersion is a const in main.go
|
builtVersion is a const in main.go
|
||||||
|
|
||||||
|
#### 1.2.4 - 18 March 2026
|
||||||
|
added check if keycard at the encoder position before trying to encode key
|
||||||
|
|
||||||
#### 1.2.3 - 17 March 2026
|
#### 1.2.3 - 17 March 2026
|
||||||
added check if keycard at the encoder position before trying to encode key
|
added check if keycard at the encoder position before trying to encode key
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user