Skip to content

Commit

Permalink
Change naming of constant from EXAMPLE_CONSTANT to ExampleConstant
Browse files Browse the repository at this point in the history
Go naming convention is to spell constants like ExampleConstant. Better change
the naming as long as nobody depends on this library.
  • Loading branch information
clausecker committed Apr 6, 2014
1 parent 12577f7 commit 68f9c91
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 52 deletions.
8 changes: 4 additions & 4 deletions dev/nfc/etc.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,11 +118,11 @@ func (c *context) listDevices() ([]string, error) {
return nil, Error(dev.count)
}

dev_entries := C.GoBytes(unsafe.Pointer(dev.entries), dev.count*BUFSIZE_CONNSTRING)
dev_entries := C.GoBytes(unsafe.Pointer(dev.entries), dev.count*BufsizeConnstring)

devices := make([]string, dev.count)
for i := range devices {
charptr := (*C.char)(unsafe.Pointer(&dev_entries[i*BUFSIZE_CONNSTRING]))
charptr := (*C.char)(unsafe.Pointer(&dev_entries[i*BufsizeConnstring]))
devices[i] = connstring{charptr}.String()
}

Expand All @@ -135,7 +135,7 @@ type connstring struct {
}

func (c connstring) String() string {
str := C.GoStringN(c.ptr, BUFSIZE_CONNSTRING)
str := C.GoStringN(c.ptr, BufsizeConnstring)
i := 0

for ; i < len(str) && str[i] != '\000'; i++ {
Expand All @@ -152,7 +152,7 @@ func newConnstring(s string) (connstring, error) {
return connstring{nil}, nil
}

if len(s) >= BUFSIZE_CONNSTRING {
if len(s) >= BufsizeConnstring {
return connstring{nil}, errors.New("String too long for Connstring")
}

Expand Down
54 changes: 27 additions & 27 deletions dev/nfc/nfc.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,24 +23,24 @@ package nfc
import "fmt"

// Maximum length for an NFC connection string
const BUFSIZE_CONNSTRING = 1024
const BufsizeConnstring = 1024

// Properties for (*Device).SetPropertyInt() and (*Device).SetPropertyBool().
const (
// Default command processing timeout
// Property value's (duration) unit is ms and 0 means no timeout (infinite).
// Default value is set by driver layer
TIMEOUT_COMMAND = iota
TimeoutCommand = iota

// Timeout between ATR_REQ and ATR_RES
// When the device is in initiator mode, a target is considered as mute
// if no valid ATR_RES is received within this timeout value.
// Default value for this property is 103 ms on PN53x based devices.
TIMEOUT_ATR
TimeoutATR

// Timeout value to give up reception from the target in case of no answer.
// Default value for this property is 52 ms).
TIMEOUT_COM
TimeoutCom

// Let the PN53X chip handle the CRC bytes. This means that the chip
// appends the CRC bytes to the frames that are transmitted. It will
Expand All @@ -50,7 +50,7 @@ const (
// Example frames where this is useful are the ATQA and UID+BCC that are
// transmitted without CRC bytes during the anti-collision phase of the
// ISO14443-A protocol.
HANDLE_CRC
HandleCRC

// Parity bits in the network layer of ISO14443-A are by default
// generated and validated in the PN53X chip. This is a very convenient
Expand All @@ -64,33 +64,33 @@ const (

// This option can be used to enable or disable the electronic field of
// the NFC device.
ACTIVATE_FIELD
ActivateField

// The internal CRYPTO1 co-processor can be used to transmit messages
// encrypted. This option is automatically activated after a successful
// MIFARE Classic authentication.
ACTIVATE_CRYPTO1
ActivateCrypto1

// The default configuration defines that the PN53X chip will try
// indefinitely to invite a tag in the field to respond. This could be
// desired when it is certain a tag will enter the field. On the other
// hand, when this is uncertain, it will block the application. This
// option could best be compared to the (NON)BLOCKING option used by
// (socket)network programming.
INFINITE_SELECT
InfiniteSelect

// If this option is enabled, frames that carry less than 4 bits are
// allowed. According to the standards these frames should normally be
// handles as invalid frames.
ACCEPT_INVALID_FRAMES
AcceptInvalidFrames

// If the NFC device should only listen to frames, it could be useful to
// let it gather multiple frames in a sequence. They will be stored in
// the internal FIFO of the PN53X chip. This could be retrieved by using
// the receive data functions. Note that if the chip runs out of bytes
// (FIFO = 64 bytes long), it will overwrite the first received frames,
// so quick retrieving of the received data is desirable.
ACCEPT_MULTIPLE_FRAMES
AcceptMultipleFrames

// This option can be used to enable or disable the auto-switching mode
// to ISO14443-4 is device is compliant.
Expand All @@ -99,46 +99,46 @@ const (
// ISO14443-4 card when ISO14443A is requested.
// In target mode, with a NFC chip compliant (ie. PN532), the chip will
// emulate a 14443-4 PICC using hardware capability.
AUTO_ISO14443_4
AutoISO14443_4

// Use automatic frames encapsulation and chaining.
EASY_FRAMING
EasyFraming

// Force the chip to switch in ISO14443-A
FORCE_ISO14443_A
ForceISO14443a

// Force the chip to switch in ISO14443-B
FORCE_ISO14443_B
ForceISO14443b

// Force the chip to run at 106 kbps
FORCE_SPEED_106
ForceSpeed106
)

// NFC modulation types
const (
ISO14443A = iota + 1
JEWEL
ISO14443B
ISO14443BI // pre-ISO14443B aka ISO/IEC 14443 B' or Type B'
ISO14443B2SR // ISO14443-2B ST SRx
ISO14443a = iota + 1
Jewel
ISO14443b
ISO14443bi // pre-ISO14443B aka ISO/IEC 14443 B' or Type B'
ISO14443b2sr // ISO14443-2B ST SRx
ISO14443B2CT // ISO14443-2B ASK CTx
FELICA
Felica
DEP
)

// NFC baud rates. UNDEFINED is also a valid baud rate, albeit defined
// further below.
const (
NBR_106 = iota + 1
NBR_212
NBR_424
NBR_847
Nbr_106 = iota + 1
Nbr_212
Nbr_424
Nbr_847
)

// NFC modes. An NFC device can either be a target or an initiator.
const (
TARGET = iota
INITIATOR
TargetMode = iota
InitiatorMode
)

// NFC modulation structure. Use the supplied constants.
Expand Down
42 changes: 21 additions & 21 deletions dev/nfc/target.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,25 +97,25 @@ func unmarshallTarget(t *C.nfc_target) Target {
m := Modulation{Type: int(t.nm.nmt), BaudRate: int(t.nm.nbr)}

switch m.Type {
case ISO14443A:
case ISO14443a:
r := unmarshallISO14443aTarget((*C.nfc_iso14443a_info)(ptr), m)
return &r
case JEWEL:
case Jewel:
r := unmarshallJewelTarget((*C.nfc_jewel_info)(ptr), m)
return &r
case ISO14443B:
case ISO14443b:
r := unmarshallISO14443bTarget((*C.nfc_iso14443b_info)(ptr), m)
return &r
case ISO14443BI:
case ISO14443bi:
r := unmarshallISO14443biTarget((*C.nfc_iso14443bi_info)(ptr), m)
return &r
case ISO14443B2SR:
case ISO14443b2sr:
r := unmarshallISO14443b2srTarget((*C.nfc_iso14443b2sr_info)(ptr), m)
return &r
case ISO14443B2CT:
r := unmarshallISO14443b2ctTarget((*C.nfc_iso14443b2ct_info)(ptr), m)
return &r
case FELICA:
case Felica:
r := unmarshallFelicaTarget((*C.nfc_felica_info)(ptr), m)
return &r
case DEP:
Expand All @@ -128,9 +128,9 @@ func unmarshallTarget(t *C.nfc_target) Target {

// NFC D.E.P. (Data Exchange Protocol) active/passive mode
const (
UNDEFINED = iota
PASSIVE
ACTIVE
Undefined = iota
Passive
Active
)

// NFC target information in D.E.P. (Data Exchange Protocol) see ISO/IEC 18092
Expand Down Expand Up @@ -214,7 +214,7 @@ func (t *ISO14443aTarget) String() string {

// Type is always ISO14443A
func (t *ISO14443aTarget) Modulation() Modulation {
return Modulation{ISO14443A, t.Baud}
return Modulation{ISO14443a, t.Baud}
}

// Make an ISO14443aTarget from an nfc_iso14443a_info
Expand All @@ -232,7 +232,7 @@ func unmarshallISO14443aTarget(c *C.nfc_iso14443a_info, m Modulation) ISO14443aT

// See documentation in Target for more details.
func (d *ISO14443aTarget) Marshall() uintptr {
c := (*C.nfc_iso14443a_info)(makeTarget(ISO14443A, d.Baud))
c := (*C.nfc_iso14443a_info)(makeTarget(ISO14443a, d.Baud))

c.abtAtqa[0] = C.uint8_t(d.Atqa[0])
c.abtAtqa[1] = C.uint8_t(d.Atqa[1])
Expand Down Expand Up @@ -267,7 +267,7 @@ func (t *FelicaTarget) String() string {

// Type is always FELICA
func (t *FelicaTarget) Modulation() Modulation {
return Modulation{FELICA, t.Baud}
return Modulation{Felica, t.Baud}
}

// Make an FelicaTarget from an nfc_felica_info
Expand All @@ -294,7 +294,7 @@ func unmarshallFelicaTarget(c *C.nfc_felica_info, m Modulation) FelicaTarget {

// See documentation in Target for more details.
func (d *FelicaTarget) Marshall() uintptr {
c := (*C.nfc_felica_info)(makeTarget(FELICA, d.Baud))
c := (*C.nfc_felica_info)(makeTarget(Felica, d.Baud))

c.szLen = C.size_t(d.Len)
c.btResCode = C.uint8_t(d.ResCode)
Expand Down Expand Up @@ -328,7 +328,7 @@ func (t *ISO14443bTarget) String() string {

// Type is always ISO14443B
func (t *ISO14443bTarget) Modulation() Modulation {
return Modulation{ISO14443B, t.Baud}
return Modulation{ISO14443b, t.Baud}
}

// Make an ISO14443bTarget from an nfc_iso14443b_info
Expand All @@ -352,7 +352,7 @@ func unmarshallISO14443bTarget(c *C.nfc_iso14443b_info, m Modulation) ISO14443bT

// See documentation in Target for more details.
func (d *ISO14443bTarget) Marshall() uintptr {
c := (*C.nfc_iso14443b_info)(makeTarget(ISO14443B, d.Baud))
c := (*C.nfc_iso14443b_info)(makeTarget(ISO14443b, d.Baud))

c.ui8CardIdentifier = C.uint8_t(d.CardIdentifier)

Expand Down Expand Up @@ -386,7 +386,7 @@ func (t *ISO14443biTarget) String() string {

// Type is always ISO14443BI
func (t *ISO14443biTarget) Modulation() Modulation {
return Modulation{ISO14443BI, t.Baud}
return Modulation{ISO14443bi, t.Baud}
}

// Make an ISO14443biTarget from an nfc_iso14443bi_info
Expand All @@ -407,7 +407,7 @@ func unmarshallISO14443biTarget(c *C.nfc_iso14443bi_info, m Modulation) ISO14443

// See documentation in Target for more details.
func (d *ISO14443biTarget) Marshall() uintptr {
c := (*C.nfc_iso14443bi_info)(makeTarget(ISO14443BI, d.Baud))
c := (*C.nfc_iso14443bi_info)(makeTarget(ISO14443bi, d.Baud))

c.btVerLog = C.uint8_t(d.VerLog)
c.btConfig = C.uint8_t(d.Config)
Expand Down Expand Up @@ -435,7 +435,7 @@ func (t *ISO14443b2srTarget) String() string {

// Type is always ISO14443B2SR
func (t *ISO14443b2srTarget) Modulation() Modulation {
return Modulation{ISO14443B2SR, t.Baud}
return Modulation{ISO14443b2sr, t.Baud}
}

// Make an ISO14443b2srTarget from an nfc_iso14443b2sr_info
Expand All @@ -451,7 +451,7 @@ func unmarshallISO14443b2srTarget(c *C.nfc_iso14443b2sr_info, m Modulation) ISO1

// See documentation in Target for more details.
func (d *ISO14443b2srTarget) Marshall() uintptr {
c := (*C.nfc_iso14443b2sr_info)(makeTarget(ISO14443B2SR, d.Baud))
c := (*C.nfc_iso14443b2sr_info)(makeTarget(ISO14443b2sr, d.Baud))

for i, b := range d.UID {
c.abtUID[i] = C.uint8_t(b)
Expand Down Expand Up @@ -519,7 +519,7 @@ func (t *JewelTarget) String() string {

// Type is always JEWEL
func (t *JewelTarget) Modulation() Modulation {
return Modulation{JEWEL, t.Baud}
return Modulation{Jewel, t.Baud}
}

// Make a JewelTarget from an nfc_jewel_info
Expand All @@ -537,7 +537,7 @@ func unmarshallJewelTarget(c *C.nfc_jewel_info, m Modulation) JewelTarget {
}

func (d *JewelTarget) Marshall() uintptr {
c := (*C.nfc_jewel_info)(makeTarget(JEWEL, d.Baud))
c := (*C.nfc_jewel_info)(makeTarget(Jewel, d.Baud))

c.btSensRes[0] = C.uint8_t(d.SensRes[0])
c.btSensRes[1] = C.uint8_t(d.SensRes[1])
Expand Down

0 comments on commit 68f9c91

Please sign in to comment.