'잡동사니'에 해당되는 글 13451건

  1. 2023.05.16 golang 고루틴과 채널
  2. 2023.05.16 xilinx uartlite on zynq
  3. 2023.05.16 golang switch, select
  4. 2023.05.16 golang uds
  5. 2023.05.16 golang mutex (sync)
  6. 2023.05.15 앵무새와 cites
  7. 2023.05.15 전기, 가스 요금 인상
  8. 2023.05.14 altera(intel fpga) m9k m10k
  9. 2023.05.14 altera uart ip
  10. 2023.05.13 낮잠 기절
Programming/golang2023. 5. 16. 15:39

채널의 경우 1개로 해두면 하나가 들어갈 때 까지 해당 위치에서 블로킹 된다.

아래 예제는 받는 부분을 삭제했는데 그렇기에 채널을 통해 전송은 되지만 수신하지 않아 비워지지 않기 때문에

one을 출력하지 못하고 멈춰있는 것을 확인할 수 있다.

package main

import (
f "fmt"
"time"
)

func main() {

f.Println("select")

c1 := make(chan string)
c2 := make(chan string)

go func() {
time.Sleep(time.Second * 1)
f.Println("---")
c1 <- "one"
f.Println("one")
c1 <- "two"
f.Println("two")
c1 <- "three"
f.Println("three")
c1 <- "four"
f.Println("four")
}()

go func() {
time.Sleep(time.Second * 2)
c2 <- "fifth"
}()

for i := 0; i < 10000000000; i++ {
time.Sleep(time.Second)
}

}
$ go run go.go 
select
---
^Csignal: interrupt

 

다만, make를 통해 채널 버퍼를 n개로 만들어 두면, 넣을 수 있는 동안은 넣고 블로킹 되지 않고 넘어갈 수 있다.

package main

import (
f "fmt"
"time"
)

func main() {

f.Println("select")

c1 := make(chan string, 4)
c2 := make(chan string)

go func() {
time.Sleep(time.Second * 1)
f.Println("---")
c1 <- "one"
f.Println("one")
c1 <- "two"
f.Println("two")
c1 <- "three"
f.Println("three")
c1 <- "four"
f.Println("four")
}()

go func() {
time.Sleep(time.Second * 2)
c2 <- "fifth"
}()

for i := 0; i < 10000000000; i++ {
time.Sleep(time.Second)
}

}
$ go run go.go 
select
---
one
two
three
four
^Csignal: interrupt

 

[링크 : https://judo0179.tistory.com/88]

'Programming > golang' 카테고리의 다른 글

golang echo server middleware  (0) 2023.05.24
golang 동시성  (0) 2023.05.24
golang switch, select  (0) 2023.05.16
golang uds  (0) 2023.05.16
golang mutex (sync)  (0) 2023.05.16
Posted by 구차니
embeded/FPGA - XILINX2023. 5. 16. 12:05

커널에서 xilinx uartlite 쓰도록 해주고

device tree에서 axi 주소 추가해주고

vivado block design에서 axi와 PS로 uartlite  블록을 연결해주면 되는건가?

[링크 : https://xilinx-wiki.atlassian.net/wiki/spaces/A/pages/18842249/Uartlite+Driver]

'embeded > FPGA - XILINX' 카테고리의 다른 글

zynq fsbl  (0) 2023.07.07
zynq w/o ps  (0) 2023.06.30
xilinx vivado uart ip  (0) 2023.05.12
xilinx bram uram  (0) 2023.05.12
xilinx - partial bitstream  (0) 2023.04.24
Posted by 구차니
Programming/golang2023. 5. 16. 11:32

golang switch는 신형 언어에 확장되서 그런가 꽤나 만능이다.

특이하게 조건식도 가능하고, 케이스 리스트도 된다.(c#에서 얼핏 봤던 느낌..)

package main

import (
"fmt"
"time"
)

func main() {
t := time.Now()
switch {
case t.Hour() < 12:
fmt.Println("Good morning!")
case t.Hour() < 17:
fmt.Println("Good afternoon.")
default:
fmt.Println("Good evening.")
}
}

[링크 :https://go.dev/tour/flowcontrol/11]

 

func WhiteSpace(c rune) bool {
switch c {
case ' ', '\t', '\n', '\f', '\r':
return true
}
return false
}

[링크 : https://hamait.tistory.com/1017]

 

아무튼 select는 channel 처리에 좀더 특화된 구문으로 생긴것 자체는 switch - case와 동일하게 작성된다.

다만, 동시에 여러개가 들어왔을 경우 랜덤하게 실행된다고 한다.

(생각이 꼬였는지 동시에 들어오면 가장 위에꺼 부터 실행되어야 하는거 아냐? 싶은데 동시성이니까 랜덤하게 처리되는건가..)

The select statement lets a goroutine wait on multiple communication operations.

A select blocks until one of its cases can run, then it executes that case. It chooses one at random if multiple are ready.

 

package main

import "fmt"

func fibonacci(c, quit chan int) {
x, y := 0, 1
for {
select {
case c <- x:
x, y = y, x+y
case <-quit:
fmt.Println("quit")
return
}
}
}

func main() {
c := make(chan int)
quit := make(chan int)
go func() {
for i := 0; i < 10; i++ {
fmt.Println(<-c)
}
quit <- 0
}()
fibonacci(c, quit)
}

[링크 : https://go.dev/tour/concurrency/5]

 

[링크 : https://edu.goorm.io/learn/lecture/2010/한-눈에-끝내는-고랭-기초/lesson/382961/채널-select문]

 

'Programming > golang' 카테고리의 다른 글

golang 동시성  (0) 2023.05.24
golang 고루틴과 채널  (0) 2023.05.16
golang uds  (0) 2023.05.16
golang mutex (sync)  (0) 2023.05.16
go 포맷터  (0) 2023.05.11
Posted by 구차니
Programming/golang2023. 5. 16. 10:46

쓸만하려나?

server client
package main

import (
"fmt"
"log"
"os"
"path/filepath"
"time"

"github.com/google/uuid"
"github.com/johnsiilver/golib/ipc/uds"
)

func main() {
socketAddr := filepath.Join(os.TempDir(), uuid.New().String())

cred, _, err := uds.Current()
if err != nil {
panic(err)
}

// This will set the socket file to have a uid and gid of whatever the
// current user is. 0770 will be set for the file permissions (though on some
// systems the sticky bit gets set, resulting in 1770.
serv, err := uds.NewServer(socketAddr, cred.UID.Int(), cred.GID.Int(), 0770)
if err != nil {
panic(err)
}

fmt.Println("Listening on socket: ", socketAddr)

// This listens for a client connecting and returns the connection object.
for conn := range serv.Conn() {
conn := conn

// We spinoff handling of this connection to its own goroutine and
// go back to listening for another connection.
go func() {
// We are checking the client's user ID to make sure its the same
// user ID or we reject it. Cred objects give you the user's
// uid/gid/pid for filtering.
if conn.Cred.UID.Int() != cred.UID.Int() {
log.Printf("unauthorized user uid %d attempted a connection", conn.Cred.UID.Int())
conn.Close()
return
}
// Write to the stream every 10 seconds until the connection closes.
for {
if _, err := conn.Write([]byte(fmt.Sprintf("%s\n", time.Now().UTC()))); err != nil {
conn.Close()
}
time.Sleep(10 * time.Second)
}
}()
}
}
package main

import (
"flag"
"fmt"
"io"
"os"

"github.com/johnsiilver/golib/ipc/uds"
)

var (
addr = flag.String("addr", "", "The path to the unix socket to dial")
)

func main() {
flag.Parse()

if *addr == "" {
fmt.Println("did not pass --addr")
os.Exit(1)
}

cred, _, err := uds.Current()
if err != nil {
panic(err)
}

// Connects to the server at socketAddr that must have the file uid/gid of
// our current user and one of the os.FileMode specified.
client, err := uds.NewClient(*addr, cred.UID.Int(), cred.GID.Int(), []os.FileMode{0770, 1770})
if err != nil {
fmt.Println(err)
os.Exit(1)
}

// client implements io.ReadWriteCloser and this will print to the screen
// whatever the server sends until the connection is closed.
io.Copy(os.Stdout, client)
}

[링크 : https://github.com/johnsiilver/golib/blob/v1.1.2/ipc/uds/example/server/server.go]

[링크 : https://github.com/johnsiilver/golib/blob/v1.1.2/ipc/uds/example/client/client.go]

[링크 : https://pkg.go.dev/github.com/johnsiilver/golib/ipc/uds]

'Programming > golang' 카테고리의 다른 글

golang 고루틴과 채널  (0) 2023.05.16
golang switch, select  (0) 2023.05.16
golang mutex (sync)  (0) 2023.05.16
go 포맷터  (0) 2023.05.11
golang echo directory listing  (0) 2023.05.08
Posted by 구차니
Programming/golang2023. 5. 16. 10:36

 

package main

import (
"fmt"
"sync"
"time"
)

// SafeCounter is safe to use concurrently.
type SafeCounter struct {
mu sync.Mutex
v  map[string]int
}

// Inc increments the counter for the given key.
func (c *SafeCounter) Inc(key string) {
c.mu.Lock()
// Lock so only one goroutine at a time can access the map c.v.
c.v[key]++
c.mu.Unlock()
}

// Value returns the current value of the counter for the given key.
func (c *SafeCounter) Value(key string) int {
c.mu.Lock()
// Lock so only one goroutine at a time can access the map c.v.
defer c.mu.Unlock()
return c.v[key]
}

func main() {
c := SafeCounter{v: make(map[string]int)}
for i := 0; i < 1000; i++ {
go c.Inc("somekey")
}

time.Sleep(time.Second)
fmt.Println(c.Value("somekey"))
}

[링크 : https://go.dev/tour/concurrency/9]

 

func (*Mutex) Lock ¶
func (m *Mutex) Lock()
Lock locks m. If the lock is already in use, the calling goroutine blocks until the mutex is available.

func (*Mutex) TryLock ¶
added in go1.18
func (m *Mutex) TryLock() bool
TryLock tries to lock m and reports whether it succeeded.

Note that while correct uses of TryLock do exist, they are rare, and use of TryLock is often a sign of a deeper problem in a particular use of mutexes.

func (*Mutex) Unlock ¶
func (m *Mutex) Unlock()
Unlock unlocks m. It is a run-time error if m is not locked on entry to Unlock.

A locked Mutex is not associated with a particular goroutine. It is allowed for one goroutine to lock a Mutex and then arrange for another goroutine to unlock it.

[링크 : https://pkg.go.dev/sync#Mutex.Lock]

 

[링크 : https://mingrammer.com/gobyexample/mutexes/]

[링크 : https://www.joinc.co.kr/w/GoLang/example/mutexex]

[링크 : https://pyrasis.com/book/GoForTheReallyImpatient/Unit35]

 

'Programming > golang' 카테고리의 다른 글

golang switch, select  (0) 2023.05.16
golang uds  (0) 2023.05.16
go 포맷터  (0) 2023.05.11
golang echo directory listing  (0) 2023.05.08
golang websocket binary  (0) 2023.03.28
Posted by 구차니

사이테스 관련 자료가 별로 없다. 아무튼 힌트가 될 만한 건.. 사이테스 간소화라는 것..

현제 그린칙코뉴어는 사이테스.간소화로 양도양수 폐사신고 이두가진 제외됬지만.
​인공증식서류 는 받으셔야 합니다.ㅎ

2021.06.03.

[링크 : https://kin.naver.com/qna/detail.nhn?d1id=8&dirId=80507&docId=391393477...&spq=0]

 

찾아봐도 별로 안나오는데.. 2020.05.31 이전에 간소화 해서 등록하라고 했었는 것 정도만 공문으로 발견

제18차 CITES 신규 등재종 '협약 전 획득 증명 간소화' 추진
    등록자명 : 김정우     조회수 : 3,764     등록일자 : 2020.04.01     담당부서 : 자연환경과     

나. 서류 간소화 운영기간 : '20.5.31.까지

[링크 : https://www.me.go.kr/wonju/web/board/read.do?pagerOffset=0&maxPageItems=10&maxIndexPages=10&searchKey=&searchValue=&menuId=1035&orgCd=&boardId=1362660&boardMasterId=232&boardCategoryId=304&decorator=]

 

환경부 가서 검색해보자

부속서 Ⅱ와 Ⅲ에는 멸종위기종 외에도 앵무새류, 육지거북류 등 일명 '예비' 멸종위기종이 포함된다. 이들은 엄격한 거래 규제가 없으면 멸종위기에 처할 수 있기 때문에 사전 신고 후 상업, 학술, 연구 목적으로 거래할 수 있으며, 부속서 Ⅲ의 경우 규제가 조금 더 느슨한 편이다.

각 부속서에 속하는 생물 목록은 CITES 공식 홈페이지나 환경부 웹사이트에서 '국제적 멸종위기종'을 검색해 확인할 수 있다.

[링크 : https://www.newspenguin.com/news/articleView.html?idxno=12901]

 

 

조류 부속서 2에 의해서 앵무가 4가지 보이긴 한데.. 누가 누구지?

양도·양수, 폐사·질병신고 제외대상 국제적 멸종위기종
[시행 2021. 12. 6.] [환경부고시 제2021-261호, 2021. 12. 6., 일부개정]


[링크 : https://www.law.go.kr/DRF/lawService.do?OC=me_pr&target=admrul&ID=2100000206707&type=HTML&mobileYn=]

 

+

그린칙 코뉴어로 알려진 .. 라고 나오고 학명이 pyrrhura molinae 인 듯.

즉, 위에 기재된 초록뺨비늘앵무고, 신고 제외대상이다. (2021.12.06) 라고 보면 될 듯.

The green-cheeked parakeet (Pyrrhura molinae), known as the green-cheeked conure in aviculture, is a species of bird in subfamily Arinae of the family Psittacidae, the African and New World parrots.[3] It is found in Argentina, Bolivia, Brazil, and Paraguay.

[링크 : https://en.wikipedia.org/wiki/Green-cheeked_parakeet]

+ end

 

부속서 2에 속한다고 했으니, 앵무목 전종이라고 봐야하려나?

국제적 멸종위기종 목록
[시행 2023. 2. 23.] [환경부고시 제2023-45호, 2023. 2. 23., 일부개정]









[링크 : https://www.law.go.kr/행정규칙/국제적멸종위기종목록/(2023-45,20230223)]

 

수입 또는 반입이 가능한 국제적멸종위기종(조류, 포유류)
[시행 2017. 1. 2.] [환경부고시 제2016-252호, 2017. 1. 2., 일부개정]

[링크 : https://www.law.go.kr/행정규칙/수입또는반입이가능한국제적멸종위기종(조류,포유류)/(2016-252,20170102)]

 

수입 또는 반입이 가능한 국제적멸종위기종(조류, 포유류)
[시행 2017. 1. 2.] [환경부고시 제2016-252호, 2017. 1. 2., 일부개정]

제2조(수입 또는 반입이 가능한 국제적멸종위기종) 수입 또는 반입이 가능한 국제적멸종위기종(조류, 포유류)은 앵무목(PSITTACIFORMES) 전 종, 문조(Lonchura oryzivora) 및 검은턱금정조(Poephila cincta cincta)이다.

[링크 : https://www.law.go.kr/행정규칙/수입또는반입이가능한국제적멸종위기종(조류,포유류)/(2016-252,20170102)]

 

썬 코뉴어 앵무 (Sun Conure)
황금빛 태양을 닮았다고 해서 '썬코뉴어 앵무', '태양앵무' 라고 불립니다!
학명은 Aratinga solstitialis 입니다 !
(아라팅아,,솔스디셜리스...영어는 언제나 어렵습니다..^^)
썬코뉴어는 코뉴어 앵무(Pyrrhure molinae) 랑 다른 학명을 사용하고있습니다.
Aratinga 종의 코뉴어들은 
젠다이 코뉴어, 난데이 코뉴어, 블루 크라운 코뉴어, 레드막코뉴어 등이 속해 있습니다.

[링크 : https://m.blog.naver.com/gozip14/221814526892]

 

'개소리 왈왈 > 육아관련 주저리' 카테고리의 다른 글

기절  (0) 2023.06.03
  (0) 2023.05.28
낮잠 기절  (0) 2023.05.13
휴가 10일차  (2) 2023.05.07
휴가 9일차  (0) 2023.05.06
Posted by 구차니

5월인데 이번년도 두번째 인상

연초에 올라서 200kwh에 3만원대 기록하게 되었는데 또 오른다니.. 이제 월 200kwh도 과소비니

더 전기를 쓰지 말라! 인 시대가 되는 듯 -_-

 

요건 올해 초에 인상

전기요금 인상 발표…내년 1분기 kWh당 13.1원

[링크 : https://www.yonhapnewstv.co.kr/news/MYH20221230007000641]

 

5월 16일자 적용되면 올해만 21원 인상

전기는 ㎾h(킬로와트시) 당 8원이 인상되면서 4인 가구 기준 월 3000원 가량 부담이 늘게 됐다. 가스는 MJ(메가줄) 당 1.04원 올라 월 4400원의 비용이 증가한다.

[링크 : https://v.daum.net/v/20230515094744649]

[링크 : https://v.daum.net/v/20230515092024433]

 

 

혹시나 무슨 소리를 써놨나 해서 가봤더니

 

임원도 아니고 임직원 임금 반납 14년중 7차례했다고(14*12=168 개월 중 7차례. 2년에 한달치 급여. 적은건 아니지만..)

그 와중에 임금 인상분을 전부 반납이라는게 웃기다. 성의를 보이려면 최소한

임원급들 전원 임금 자체를 50% 삭감한다거나 했으면 모를까. (혹은 최저임금 제외하고 전부 반납)

그리고 적자라면서 매년 인센티브는 받아가면서 그거 이야기도 없고. 그러니 싸늘할 수 밖에

 

한국전력. 창사이래 최대규모 자구노력 추진

□ (임금 반납) 한전 및 전력그룹사는 그동안 국가나 회사가 어려울 때마다 자발적으로 임금 반납*을 시행해왔으며, 그 일환으로 지난해에도 경영진과 1직급 이상 간부의 성과급 및 임금을 반납하였음* 2008년부터 2022년까지 총 7차례에 걸쳐 자발적으로 임직원 임금 반납
금년에도 사상 초유의 재무위기 극복에 책임있는 자세로 앞장서고 국민고통을 분담하기 위해 임직원의 임금 인상분을 반납하기로 결정하였으며, 반납한 임금 인상분은 취약계층 지원에 활용할 계획임
○ 우선, 국민과 고통을 분담하는 차원에서 한전과 전력그룹사는 2직급 이상 임직원의 임금 인상분을 전부 반납하고, 한전은 추가로 3직급 직원의 임금 인상분의 50%를 반납 하기로 하였음
※ 성과급은 경영평가 결과가 확정되는 6월경 1직급 이상은 전액,2직급 직원은 50% 반납할 계획
○ 여기에 더해 전 직원의 동참도 추진 하기로 하였음. 다만, 노동조합원인직원의 동참은 노조와의 합의가 필요한 만큼, 이날 한전은 노조도동참해 줄 것을 공식 요청했다고 밝힘

[링크 : https://home.kepco.co.kr/kepco/PR/ntcob/ntcobView.do?pageIndex=1&boardSeq=21061937&boardCd=BRD_000117&menuCd=FN060306&parnScrpSeq=0&searchCondition=total&searchKeyword=]

 

 

 

 

100.6 -> 112.0 -> 120.0 작년대비 20% 인상인데(200kwh 구간 ) 체감은 그렇지 않다는게 함정..

 

(아래는 저압기준)

가장 많이 쓰는 구간이 400kwh 이하일테고 300kwh를 기준으로 잡는다면

195.2 * 300 = 58,560 (작년말)

206.6 * 300 = 61,980 (올해초)

214.6 * 300 = 64,380 (6월) 의외로 별로 안오른것 같은데 착각인가?

 

[링크 : https://cyber.kepco.co.kr/ckepco/front/jsp/CY/E/E/CYEEHP00101.jsp]

 

 

+

누진제 개편으로 여름철 전기요금 부담 완화 상시화
산업통상자원부 에너지자원실 에너지혁신정책관 전력시장과 2019.07.01 2p 다운로드
관련주제시계열
산업통상자원부는 한국전력공사가 제출한 누진제 개편을 위한 전기공급 약관 변경(안)을 관계부처 협의, 전기위 심의를 거쳐 7.1.(월) 최종인가하여 시행할 예정이라고 밝혔다.

- 이번 요금 개편은 7-8월에 한해 누진구간을 확대하는 방식으로 누진 1단계 구간을 기존 0-200kwh에서 0-300kwh(100kwh 추가)로, 누진 2단계 구간을 기존 201-400kwh에서 301-450kwh(50kwh 추가)로 조정함.

- 누진제 개편으로 여름철 전기요금 부담은 16%(폭염시) ~ 18%(평년시) 가량 감소될 것으로 기대됨.

[링크 : https://eiec.kdi.re.kr/policy/materialView.do?num=190110]

 

 

+

다시보니 2023년 1월에 바뀐건진 모르겠지만 7~8월에만 1단계가 300kw, 다른 기간에는 200kw까지 였으니

200~300kw 사이를 쓰더라도 꽤나 체감이 커질수 밖에 없는건가?

[링크 : http://www.consumertimes.kr/48217]

 

 

+

2020년꺼 보니 저압이라면 별반 차이가 없긴한데

고압이라면 154원 정도로 썼으니 체감이 클 수 밖에 없었나 싶다.

 

[링크 : https://cyber.kepco.co.kr/ckepco/front/jsp/CY/E/E/CYEEHP00307.jsp]

 

+

전기요금이 관리비에 포함되서 청구되면 고압으로 보면 될 듯.

[링크 : https://m.blog.naver.com/itcools/221334001819]

Posted by 구차니
embeded/FPGA - ALTERA2023. 5. 14. 14:38

cyclone IV 에서는 M9K 인것 같고

cyclone V 에서는 M10K 인가?

 

de10-nano 다운로드 받아서 IP catalog에서 해보니 아래와 같이 나온다.

 

M9K and M10K memories are Intel/Altera’s embedded highdensity memory arrays – Nearly all modern FPGAs include similar “block memories” • Each block contains approximately 9000 or 10,000 bits of memory per block respectively

[링크 : https://www.ece.ucdavis.edu/~bbaas/181/notes/Handout.M9K.M10K.mems.pdf]

'embeded > FPGA - ALTERA' 카테고리의 다른 글

terasic sockit  (0) 2023.11.06
HSMC(High Speed Mezzanine Card)  (0) 2023.10.02
altera uart ip  (0) 2023.05.14
altera - partial reconfigure  (0) 2023.04.24
altera nios 2 epcs to ram  (0) 2023.03.28
Posted by 구차니
embeded/FPGA - ALTERA2023. 5. 14. 12:56

xilinx 에서 보다 intel fpga쪽 보니

라이센스 이야기도 없고(그냥 있으면 기본 무료라고 보면 되는건가..?) 웬지 불안해지는 느낌

 

얘가 HDL 레벨에서 설정해서 쓰는 간단한 uart ip고

 

16550 이 전체 사양 지원하는 uart 디바이스

 

 

cyclone iv 에서는 사용불가능한데

이름만 보면 xlinix의 uartlite 같지만, 전혀 다른 ip 같은 느낌이네..

그 와중에 시리얼 라이트라는데 내가 아는 그 시리얼이 아닌가?

'embeded > FPGA - ALTERA' 카테고리의 다른 글

HSMC(High Speed Mezzanine Card)  (0) 2023.10.02
altera(intel fpga) m9k m10k  (0) 2023.05.14
altera - partial reconfigure  (0) 2023.04.24
altera nios 2 epcs to ram  (0) 2023.03.28
Nios V  (0) 2021.11.01
Posted by 구차니

아침에 50분 더 일찍 일어나서 아내 병원 예약하고 왔는데

8시 부터 엶에도 불구하고 12시에 겨우 예약 -_-

1시간 조금 아노디게 일찍 일어난 페널티로 오전 내내 헤롱헤롱 하다가

둘째 깁스 풀고 와서는 점심 하기 전에 기절 아내가 깨워서 일어나니 4시

'개소리 왈왈 > 육아관련 주저리' 카테고리의 다른 글

  (0) 2023.05.28
앵무새와 cites  (0) 2023.05.15
휴가 10일차  (2) 2023.05.07
휴가 9일차  (0) 2023.05.06
휴가 8일차  (0) 2023.05.05
Posted by 구차니