cabrillo

package module
v0.3.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 22, 2025 License: MIT Imports: 9 Imported by: 2

README

ftl/cabrillo

This little Go library to handle the Cabrillo file format for amateur radio contest log files.

Use as a Go Library

To include cabrillo into your own projects as a library:

go get github.com/ftl/cabrillo
Read a Cabrillo log file
f, err := os.Open("mycabrillo.log")
if err != nil {
    panic(err)
}
log, err := cabrillo.Read(f)
if err != nil {
    panic(err)
}
Write a Cabrillo log file
log := cabrillo.NewLog()
log.Contest = "CQ-WW-CW"
log.Callsign = callsign.MustParse("DL0ABC")
log.Operators = []callsign.Callsign{callsign.MustParse("DL1ABC")}
log.Host = callsign.MustParse("DL1ABC")
log.Location = "DX"
log.Category.Operator = cabrillo.SingleOperator
log.Category.Assisted = cabrillo.Assisted
log.Category.Band = cabrillo.BandAll
log.Category.Power = cabrillo.HighPower
log.Category.Mode = cabrillo.ModeCW
log.Category.Transmitter = cabrillo.OneTransmitter
log.ClaimedScore = 12345
log.Club = "Bavarian Contest Club"
log.Name = "Hans Hamster"
log.Email = "hans.hamster@example.com"
log.Address.Text = "Beispielstraße 1"
log.Address.City = "Musterstadt"
log.Address.Postalcode = "12345"
log.Address.StateProvince = "Bavaria"
log.Address.Country = "Germany"
log.CreatedBy = "Golang Cabrillo Example"
log.Soapbox = "this is just an example that shows how to write Cabrillo logs in Golang"

// qsos is where you keep your QSO data in your internal representation
qsoData := make([]QSO, 0, len(qsos)) 
for _, qso := range qsos {
    // convertQSOToCabrillo converts your internal represenation to cabrillo.QSO
    qsoData = append(qsoData, convertQSOToCabrillo(qso)) 
}
log.QSOData = qsoData

f, err := os.Create("mycabrillo.log")
if err != nil {
    panic(err)
}
err = cabrillo.Write(f, log, false)
if err != nil {
    panic(err)
}

License

This software is published under the MIT License.

Copyright Florian Thienel

Documentation

Overview

Package cabrillo implements the Cabrillo V3 file format as defined by the [WWROF]

[WWROF] https://wwrof.org/cabrillo/

Index

Constants

View Source
const (
	Version2 = "2.0"
	Version3 = "3.0"
)
View Source
const TimestampLayout = "2006-01-02 1504"

Variables

This section is empty.

Functions

func ParseTimestamp

func ParseTimestamp(s string) (time.Time, error)

func Write added in v0.2.0

func Write(w io.Writer, l *Log, appendTX bool) error

func WriteWithTags added in v0.2.0

func WriteWithTags(w io.Writer, l *Log, appendTX bool, ommitIfEmpty bool, tags ...Tag) error

Types

type Address

type Address struct {
	Text          string
	City          string
	StateProvince string
	Postalcode    string
	Country       string
}

type Category

type Category struct {
	Assisted    CategoryAssisted
	Band        CategoryBand
	Mode        CategoryMode
	Operator    CategoryOperator
	Power       CategoryPower
	Station     CategoryStation
	Time        CategoryTime
	Transmitter CategoryTransmitter
	Overlay     CategoryOverlay
}

type CategoryAssisted

type CategoryAssisted string
const (
	Assisted    CategoryAssisted = "ASSISTED"
	NonAssisted CategoryAssisted = "NON-ASSISTED"
)

func (CategoryAssisted) Bool

func (c CategoryAssisted) Bool() bool

type CategoryBand

type CategoryBand string
const (
	BandAll        CategoryBand = "ALL"
	Band160m       CategoryBand = "160M"
	Band80m        CategoryBand = "80M"
	Band40m        CategoryBand = "40M"
	Band20m        CategoryBand = "20M"
	Band15m        CategoryBand = "15M"
	Band10m        CategoryBand = "10M"
	Band6m         CategoryBand = "6M"
	Band4m         CategoryBand = "4M"
	Band2m         CategoryBand = "2M"
	Band222        CategoryBand = "222"
	Band432        CategoryBand = "432"
	Band902        CategoryBand = "902"
	Band1_2G       CategoryBand = "1.2G"
	Band2_3G       CategoryBand = "2.3G"
	Band3_4G       CategoryBand = "3.4G"
	Band5_6G       CategoryBand = "5.7G"
	Band10G        CategoryBand = "10G"
	Band24G        CategoryBand = "24G"
	Band47G        CategoryBand = "47G"
	Band75G        CategoryBand = "75G"
	Band122G       CategoryBand = "122G"
	Band134G       CategoryBand = "134G"
	Band241G       CategoryBand = "241G"
	BandLight      CategoryBand = "LIGHT"
	BandVHF_3Band  CategoryBand = "VHF-3-BAND"
	BandVHF_FMOnly CategoryBand = "VHF-FM-ONLY"
)

type CategoryMode

type CategoryMode string
const (
	ModeCW    CategoryMode = "CW"
	ModeDIGI  CategoryMode = "DIGI"
	ModeFM    CategoryMode = "FM"
	ModeRTTY  CategoryMode = "RTTY"
	ModeSSB   CategoryMode = "SSB"
	ModeMIXED CategoryMode = "MIXED"
)

type CategoryOperator

type CategoryOperator string
const (
	SingleOperator CategoryOperator = "SINGLE-OP"
	MultiOperator  CategoryOperator = "MULTI-OP"
	Checklog       CategoryOperator = "CHECKLOG"
)

type CategoryOverlay

type CategoryOverlay string
const (
	ClassicOverlay    CategoryOverlay = "CLASSIC"
	RookieOverlay     CategoryOverlay = "ROOKIE"
	TBWiresOverlay    CategoryOverlay = "TB-WIRES"
	YouthOverlay      CategoryOverlay = "YOUTH"
	NoviceTechOverlay CategoryOverlay = "NOVICE-TECH"
	Over50Overlay     CategoryOverlay = "OVER-50"
	YLOverlay         CategoryOverlay = "YL"
)

type CategoryPower

type CategoryPower string
const (
	HighPower CategoryPower = "HIGH"
	LowPower  CategoryPower = "LOW"
	QRP       CategoryPower = "QRP"
)

type CategoryStation

type CategoryStation string
const (
	DistributedStation    CategoryStation = "DISTRIBUTED"
	FixedStation          CategoryStation = "FIXED"
	MobileStation         CategoryStation = "MOBILE"
	PortableStation       CategoryStation = "PORTABLE"
	RoverStation          CategoryStation = "ROVER"
	RoverLimitedStation   CategoryStation = "ROVER-LIMITED"
	RoverUnlimitedStation CategoryStation = "ROVER-UNLIMITED"
	ExpeditionStation     CategoryStation = "EXPEDITION"
	HQStation             CategoryStation = "HQ"
	SchoolStation         CategoryStation = "SCHOOL"
	ExplorerStation       CategoryStation = "EXPLORER"
)

type CategoryTime

type CategoryTime string
const (
	Hours6  CategoryTime = "6-HOURS"
	Hours8  CategoryTime = "8-HOURS"
	Hours12 CategoryTime = "12-HOURS"
	Hours24 CategoryTime = "24-HOURS"
)

func (CategoryTime) Duration

func (c CategoryTime) Duration() time.Duration

type CategoryTransmitter

type CategoryTransmitter string
const (
	OneTransmitter       CategoryTransmitter = "ONE"
	TwoTransmitter       CategoryTransmitter = "TWO"
	LimitedTransmitter   CategoryTransmitter = "LIMITED"
	UnlimitedTransmitter CategoryTransmitter = "UNLIMITED"
	SWL                  CategoryTransmitter = "SWL"
)

type ContestIdentifier

type ContestIdentifier string

type Log

type Log struct {
	CabrilloVersion string
	Callsign        callsign.Callsign
	Contest         ContestIdentifier
	Category        Category
	Certificate     bool
	ClaimedScore    int
	Club            string
	CreatedBy       string
	Email           string
	GridLocator     locator.Locator
	Location        string
	Name            string
	Address         Address
	Operators       []callsign.Callsign
	Host            callsign.Callsign
	Offtime         Offtime
	Soapbox         string
	Debug           int
	Custom          map[Tag]string
	QSOData         []QSO
	IgnoredQSOs     []QSO
	QTCData         []QTC
}

func NewLog

func NewLog() *Log

func Read

func Read(r io.Reader) (*Log, error)

type Offtime

type Offtime struct {
	Begin time.Time
	End   time.Time
}

func (Offtime) Duration

func (o Offtime) Duration() time.Duration

type QSO

type QSO struct {
	Frequency   QSOFrequency
	Mode        QSOMode
	Timestamp   time.Time
	Sent        QSOInfo
	Received    QSOInfo
	Transmitter int
}

func ParseQSO

func ParseQSO(s string) (QSO, error)

type QSOFrequency

type QSOFrequency string
const (
	Frequency50MHz  QSOFrequency = "50"
	Frequency70MHz  QSOFrequency = "70"
	Frequency144MHz QSOFrequency = "144"
	Frequency222MHz QSOFrequency = "222"
	Frequency432MHz QSOFrequency = "432"
	Frequency902MHz QSOFrequency = "902"
	Frequency1_2GHz QSOFrequency = "1.2G"
	Frequency2_3GHz QSOFrequency = "2.3G"
	Frequency3_4GHz QSOFrequency = "3.4G"
	Frequency5_7GHz QSOFrequency = "5.7G"
	Frequency10GHz  QSOFrequency = "10G"
	Frequency24GHz  QSOFrequency = "24G"
	Frequency47GHz  QSOFrequency = "47G"
	Frequency75GHz  QSOFrequency = "75G"
	Frequency122GHz QSOFrequency = "122G"
	Frequency134GHz QSOFrequency = "134G"
	Frequency241GHz QSOFrequency = "241G"
	FrequencyLight  QSOFrequency = "LIGHT"
)

func (QSOFrequency) IsFrequency

func (f QSOFrequency) IsFrequency() bool

func (QSOFrequency) ToBand

func (f QSOFrequency) ToBand() CategoryBand

func (QSOFrequency) ToKilohertz

func (f QSOFrequency) ToKilohertz() int

type QSOInfo

type QSOInfo struct {
	Call     callsign.Callsign
	Exchange []string
}

type QSOMode

type QSOMode string
const (
	QSOModeCW    QSOMode = "CW"
	QSOModePhone QSOMode = "PH"
	QSOModeFM    QSOMode = "FM"
	QSOModeRTTY  QSOMode = "RY"
	QSOModeDigi  QSOMode = "DG"
)

type QTC added in v0.3.0

type QTC struct {
	Frequency QSOFrequency
	Mode      QSOMode
	Timestamp time.Time
	RxCall    callsign.Callsign
	QTCHeader QTCHeader
	TxCall    callsign.Callsign
	QTCTime   QTCTime
	QTCCall   callsign.Callsign
	QTCNumber QTCNumber
}

func ParseQTC added in v0.3.0

func ParseQTC(s string) (QTC, error)

type QTCHeader added in v0.3.0

type QTCHeader string

type QTCNumber added in v0.3.0

type QTCNumber int

type QTCTime added in v0.3.0

type QTCTime string

type Tag

type Tag string
const (
	StartOfLogTag           Tag = "START-OF-LOG"
	EndOfLogTag             Tag = "END-OF-LOG"
	CallsignTag             Tag = "CALLSIGN"
	ContestTag              Tag = "CONTEST"
	CategoryAssistedTag     Tag = "CATEGORY-ASSISTED"
	CategoryBandTag         Tag = "CATEGORY-BAND"
	CategoryModeTag         Tag = "CATEGORY-MODE"
	CategoryOperatorTag     Tag = "CATEGORY-OPERATOR"
	CategoryPowerTag        Tag = "CATEGORY-POWER"
	CategoryStationTag      Tag = "CATEGORY-STATION"
	CategoryTimeTag         Tag = "CATEGORY-TIME"
	CategoryTransmitterTag  Tag = "CATEGORY-TRANSMITTER"
	CategoryOverlayTag      Tag = "CATEGORY-OVERLAY"
	CertificateTag          Tag = "CERTIFICATE"
	ClaimedScoreTag         Tag = "CLAIMED-SCORE"
	ClubTag                 Tag = "CLUB"
	CreatedByTag            Tag = "CREATED-BY"
	EmailTag                Tag = "EMAIL"
	GridLocatorTag          Tag = "GRID-LOCATOR"
	LocationTag             Tag = "LOCATION"
	NameTag                 Tag = "NAME"
	AddressTag              Tag = "ADDRESS"
	AddressCityTag          Tag = "ADDRESS-CITY"
	AddressStateProvinceTag Tag = "ADDRESS-STATE-PROVINCE"
	AddressPostalcodeTag    Tag = "ADDRESS-POSTALCODE"
	AddressCountryTag       Tag = "ADDRESS-COUNTRY"
	OperatorsTag            Tag = "OPERATORS"
	OfftimeTag              Tag = "OFFTIME"
	SpecificTag             Tag = "SPECIFIC"
	SoapboxTag              Tag = "SOAPBOX"
	QSOTag                  Tag = "QSO"
	QTCTag                  Tag = "QTC"
	XQSOTag                 Tag = "X-QSO"
	XPrefix                     = "X-"
)

func (Tag) IsCustom

func (t Tag) IsCustom() bool

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL